It’s a point I’ve made before, but human beings are hardwired to affirm their in-group and vilify out-groups. It takes a lot of social conditioning to get people to be polite to strangers. This also explains the continuing popularity of trade barriers and immigration restrictions, in the face of basic economics. It also explains why, despite massive improvements in recent decades, racism and homophobia will almost certainly never die. People will always look for reasons to not get along with each other.
According to Carl Sagan and Ann Druyan’s delightful 1992 book Shadows of Forgotten Ancestors, humanity’s inborn suspicion of outsiders actually predates humanity. It goes back billions of years, and has been observed in bacteria (see location 1773 of the Kindle edition):
You may be a ruthless, implacable predator, but you must also be a pushover for your relatives and neighbors. So all of you may suffuse your outer membranes with a chemical that serves for species recognition. When you taste this molecule emanating from another microbe, you become very affable. “Friend,” the chemical says. “Sister.” Other chemicals carry different information. Some bacteria routinely produce their own chemical warfare agents, antibiotics that are harmless to themselves and others of their own strain, but deadly to bacteria of different strains, foreigners. A delicate balance has evolved between hostility to the outside group and cooperation with the inside group. Them and us. The first intimations of xenophobia and ethnocentrism evolved early.