Humans are pack animals. They need to gather according to shared traits and then see an enemy of everyone who does not fit.
— Some geeky guy on Slashdot.
Computer scientists are taught classical categorization, which has little correspondence to how our brains actually categorize. The Aristotelian “necessary and sufficient” check-lists of traits, on which we’ve built giant monoliths of computer code (hello, Active Directory) and theory (hello, cladistic phylogeny) are something like the phlogiston theory; a bluntly workable model, that lets you get things done, but also fundamentally wrong, and thus a limitation on what can be understood and predicted.
Research that’s been ongoing since the 1960s or earlier, by people like Eleanor Rosch and Paul Kay, and later George Lakoff and Ronald Langacker, has provided significant amounts of data showing our brains do not assign people to us/them categories because they have a set of traits that we’ve understood and identified. In neurological reality, we assign people to categories based on how closely we think they resemble one or more prototypes, which might be real people (a group leader, typically) or an idealized belief or perception of how men and women should be. The prototype can be fixed (like, say, Jesus) or constantly changing (like, say, a political candidate).
There will always be someone in the group who least resembles the prototype, so there is always a scapegoat available if there’s not enough food or someone needs to take the blame for some unavoidable accident. There may also be anti-prototypes and whoever most resembles that person is less “in the group” than someone who is otherwise the same but lacks these correspondences with the anti-prototypes.
In a strange way this confirms one of Cipolla’s famous “basic laws of human stupidity“; since we’ve evolved a categorization method that mainly serves to quickly identify who gets thrown off the sled when the wolves are catching up, of course there will always be more than enough people to fill that role. If you need a scapegoat, you’ll always be able to identify someone as the stupid person responsible; our brains are biased to work that way.