I would say it is largely artefactual, a remnant of of a brain that was only designed to be a member of a small group (less than 100 members). In modern society where there are thousands of people you can interact with you need a shorthand to know who to trust.
Check out "less than human: Why we Demean, Enslave, and Exterminate Others".
Also, along the same lines: "Extreme mass Homicide: From military massacre to genocide." A good read along the us-versus-them line of thought.
Bookmarks