Orion-sama has pretty much explained it already.
The coding problem which resulted in 1st and 2nd Generation games being uncompatible with 3rd Generation games is no more. Thing is, Game Boy and Game Boy Color games used a 4-bit allocation. By using hexadecimal, the highest value was FF, which equals 255. They only had space for 255 Pokémon allocations. They came too close to the limit in 2nd Generation, with 251 Pokémon. Add in the consistence allocation (Better known as Missingno. for most people.) and they only had 3 spaces left for Pokémon.
Thus, they went with a 8-bit allocation in 3rd Generation and on, which also allowed them to do changes in the overall coding of the game. With 8 bits, they now have a FFF capacity with hexadecimal. That equals 4095 allocations up to use since 3rd Generation. As you see, they've just used 500 allocations in D/P (493 Pokémon + all extra forms that are allocated as different Pokémon (East Shellos/Gastrodon, Dirt and Trash Wormadam, and the other 3 forms of Deoxys.), which is 7.). Still not even close to using half the available allocations with the 8-bit memory. Not even a quarter's been used.
Which means that it's likely Pokémon Generations will remain compatible from now on. There's the chance Nintendo liked the money they got from making 3rd Generation uncompatible with the old ones, which implied most new games had to be bought in order to get all Pokémon. But I don't think they'd be so cheap to do that.
I hope so. How else are we supposed to get stuff like Mewtwo, Zapdos, etc. Unless they force events for all of them..
Expertly infact, i never knew that i just thought that it was because the data transfer between the 2nd and the 3rd generation didn't work as they traded differently.