So, I think it varies. If you’re talking about a situation like ethnic groups that have been next to one another and fighting for a long time (Hindus and Muslims for example), the first hates the second because the second hates the first and vice versa. There’s so much history and animosity built up over so long that both sides raise their kids to hate and resent the other…intentionally or not.
In terms of domestic racism, such as in the US, the main thing is ignorance. The fact is that we are racially segregated. The vast majority of blacks live in the inner cities, and especially when you get to rural whites who have grown up without contact with blacks on any serious level—in such cases, it’s easy for both groups to believe the worst about the other because they don’t have counterexamples in their lives.
Imagine growing up in rural America and all you hear about black folks is news stories from the nearest big city about crime and shootings and what not. That such folks are a small minority of blacks doesn’t dawn on you because you’ve never gotten to really know a real live black person. Maybe you met one or two…but you haven’t KNOWN them. And if your parents complained about black folks or worse, you knew some KKK people who didn’t seem like the terrorists described in the media…it wouldn’t be hard to be swayed.
Now, I’m painting the easy-mode picture. Real life is always more complicated, but I think ignorance…or perhaps a more favorable way of putting it is ‘lack of experience’ with people of the group you’ve been taught to hate…I think that’s the main driver.