It's called "families" and "communities" and is the basis for human civilization. My children aren't going to grow up around poor third world people, nor marry them or raise their own families with them. Some poor third world person isn't going to come to my aid if I'm in trouble. They're not going to be my friends, my coworker, or even the guy who might find my phone and return it to me. They won't be voting for the government that governs me. Any rational person has tremendous incentive to make sure the people closest to them, and more broadly the people in their own body politic are cared for before others.