It fulfills a social contract: the service you provide by being born is carrying your parents' genes. There is a three-way transaction between citizen, child, and state. This is a boon; it allows social contracts with long time horizons to be made. Take away preference for native-born citizens over foreigners, and you remove the incentive for citizens to leave a country better than they found it. This is not an absolute---limited naturalization, like we have, has not caused the world to fall down. But there is an effect.
I hear what you're saying and it makes sense. What would prevent such contracts from being a boon if we were all in one 'country'(the world), though? Is it to hold onto something deemed of value that some may consider arbitrary (speaking a particular language, celebrating certain holidays)? Perhaps some of the values held in certain countries are the things folks want to hold on to (personal liberty vs group cohesion, gun rights, etc). We humans are sure interesting.