Racism is connected to social anxiety. People with a rare genetic disorder called Williams syndrome, which causes people to lack social anxiety, also lack racial biases. These people are also vulnerable to attack because they don't have social fear; they don't pick up signals that someone may be about to attack them. And the beta blocker propranolol, of all things, makes people less racially prejudiced, apparently because the beta blocker blocks neural connections that are involved in subconscious fear.
Apparently one root cause of racism is a tendency to fear people who are non-kin. Fearing non-kin seems like a useful self-protection, because people who are non-kin are more likely to be aggressive with people that don't share their genes. (as in The Selfish Gene by Richard Dawkins). Someone who has a different racial appearance is usually non-kin. All cultures have racial stereotypes.
I have seen this anxiety over racism very often among white people, causing them to treat black people badly or at least make black people feel self-conscious or exclude them socially. This anxiety seems particularly high-voltage around black people vs other nonwhite people. For example, a few months ago I was at a computer repair place to get my laptop fixed, and a black guy walks in with his laptop. And the computer repair guy says "Sir, what can I do for you?" It was very obvious and exaggerated, he seemed to be trying to exonerate himself of the charge of racism and communicate to the black guy that he would treat him well, even though he was black ... He didn't call me "Madam" when I walked in because as a white woman, I didn't trigger anxiety. There was a lot of nervous laughter, it made me feel weird and it surely made the black guy feel weird too - why ever should his race be an issue, when he was just trying to get his laptop fixed?
And, I used to work in a science lab at a university and once I heard people talking in shocked tones about how our white lab manager, who needed to hire someone to wash the lab glassware, had interviewed a black guy, but he said he wouldn't hire him because he wouldn't feel comfortable working with a black person. Our lab manager was very socially anxious, and that was probably what caused him to treat this black person in a concretely damaging way.
I got a lot more comfortable around people of other races when I went gluten-free and quit eating various foods I'd become allergic to. It was a huge relief from anxiety and fear, and I got a lot more sociable and I "read" social signals much more than before. I came to understand people as social, subjective creatures. Before that, I had attributed my overwhelming anxiety to having been abused as a child - but the proximate cause turned out to be biological. Life is full of surprises that puncture one's assumptions like a balloon.