Yet mysteriously, every country in the world does this (discriminates against foreigners) to some extent, and has for recorded history. If you can't figure out why, perhaps you shouldn't be talking about policy, in the same way you shouldn't delete code you don't understand.
Although I don't necessarily agree with what GP is saying, it seems to be spreading ignorance to say "if you can't figure out why [then I'm not going tell you] and you shouldn't be talking about it". Instead of alluding to a mysterious reason, which you insist one ought to understand to talk about policy, why don't you tell us what the reason is?