The phenomenon helps explain a whole host of subconscious reactions, like prejudice against people with facial birthmarks, an attraction to symmetrical faces, and, yes, strong anti-immigration views. In some cases, the behavioral immune system might have a point: The sight of pus and blood makes some people queasy because touching another person’s infected wound without gloves is dangerous. But the behavioral immune system, like an allergy, is so sensitive that it’s often wrong. It sometimes hurts us more than it helps.

In a new review paper published this week in Advances in Experimental Social Psychology, the psychologists Damian R. Murray, from Tulane University, and Mark Schaller, from the University of British Columbia, explain where these behavioral defenses against infection came from—and how they can deceive.

The actual immune system—the one that biologically fights infection—works best against the pathogens it’s accustomed to. When European settlers reached America, they promptly infected Native Americans with measles, whooping cough, smallpox, and a number of other diseases to which they had no immunity. Today, we might experience this when we travel to new, glamorous locations and spend many un-glamorous evenings perched on the toilet with traveler’s diarrhea.

In centuries past, then, it may have been healthy to tread carefully around foreigners. Not only might outsiders carry dangerous germs, they also might not be familiar with the kinds of local customs—food-preparation laws or sexual practices—that conferred some measure of protection against communicable diseases.

The trouble is, with modern medicine most people no longer have to worry when they come into casual contact with someone from a different country. (Some researchers believe, in fact, that our lives are now too sanitary.) Still, our hypervigilant behavioral immune systems scan the landscape for foes, be they real or fake, to keep away from our delicate bodies.

A mere encounter with someone or something unfamiliar might set off our sense of disgust, an especially hair-trigger response. Here, our behavioral immune systems are helped out by the more primitive regions of the brain. According to New York University psychologist David M. Amodio, two things happen when we’re under threat and encounter a person from outside our group. First, the amygdala reacts by freezing our behavior—we stop, we stare—and preparing the body for fight or flight. And second, if the person is disliked, they might elicit a response from the insula, the brain region that generates a sense of deep-in-the-gut revulsion.

This impulse doesn’t always work in our favor. Some studies suggest the reason why pregnant women develop morning sickness in their first trimester, when their immunity is lower, is because they are more wary of infection and therefore more revolted by everything. In one study, people were less willing to eat fudge that was molded into the shape of poop, even if they knew for a fact it was fudge. The risk of accidental exposure to something harmful, our bodies seem to think, far outweighs the pleasure of a turd-shaped treat.