You probably know how the lighter the color of your skin is, the easier it is for you to make vitamin D from sunlight. And you all know how it's really easy to differentiate between different type of people by their skin color. It works even from a distance, so of course the color of the skin is one of the easiest targets for racist people. While I'm not qualified to get into the psychology of the actual hatred and fear being present in the mind of such people, it made me think of what might be the roots of this phenomenon. It would be quite hard to live together for two people who need different amount of sun exposure to be able to get the amount of vitamin D they need. People living near the equator need 6 times the amount of sunlight than the paler, northern people: https://www.nasw.org/article/vitamin-d-levels-determined-how-human-skin-color-evolved Let me theoretize something that also connects back to assortative mating. Imagine back in the days without Vitamin D supplements, it was virtually impossible to get the healthy serum levels without enough sun exposure (UV radiation), and if the pale person makes enough, he/she needs to avoid getting more and risking sunburn (and eventually skin cancer). Sure, one can keep putting on protective clothes, even sunscreen (like the ancient jasmine and rice combination), but how uncomfortable that is? And the darker skinned part of the theoretical couple would develop Vitamin D deficiency if he or she stayed in the sunlight only as long as their partner needed. So it can be at least one of those quite rational reasons with significant health benefits/drawbacks why people didn't usually mix. From then on, it's just a step for certain members of any given community to forget or be ignorant about the real reasons behind certain choices. Then the only thing left there is the fear of what is perceivably different from them, and this results in the above mentioned hatred.