When you show a baby a picture of its' mother you get a stronger reaction than if you show it a picture of a stranger. If you show a baby a picture of a stranger with similar hair color and skin tones of its' mother, you get a stronger reaction than if you show it a picture of somebody with different colored skin.
If you raise a baby animal from birth, it often bonds with you and has a difficult time mixing later with its' own kind. This is called imprinting and is common in many species, most notably birds and mammals. This has been shown time and time again and is why scientists and zoo keepers often dress up as the kind of animal they are caring for when raising orphaned or abandoned animals that are to be released into the wild.

This little moose was orphaned and is now imprinted on the woman, some animals can never return to the wild as they then lack the abitilty to relate to their own species. Photo by Alexander Mineav, from Wikimedia
If you put several animal species in a pen, they will naturally bond up with the same species as themselves, no matter how close in appearance other the other animals may be. Horses will stick with horses, cattle with cattle, donkeys with donkeys, sheep with sheep, goats with goats, and so on. If you do not give an animal a choice of its own species, it will bond up with the most similar. A single donkey will latch onto and hang out with the horses if there are no other donkeys in the pen.
People are mostly attracted to individuals of a similar race as themselves, or when raised with other races, they are often attracted to what is most familiar. Of course as society becomes more of a melting pot, people are more and more exposed to people of other races, mixed marriages become more common, and are being more accepted.
When strangers talk, they look for things they have in common with the other person, this is how friendships and relationships are established, through commonality. Opposites only attract in magnets, not in real life. It is much easier to form a relationship with a person who has a similar way of forming their thoughts and ideas. Similar backgrounds make for fewer complications, or misunderstandings.
Peer pressure is at its' height in school, when nobody really wants to stand out, because if you do, you are usually a target for harassment. Race being an easy visual thing to pick on, height, shape, or other behavioral abnormalities also become a target for ridicule. Children are not unlike chickens forming a pecking order. Somebody is at the top, somebody is at the bottom. In most homes with pets, the home owner will note that the pets even form pecking orders of some sort. Farmers know that their animals are not just a big herd of friends, somebody is usually first to eat, and somebody is often last.
People have higher intelligence levels and are supposed to be able to overcome these primitive patterns. Not all do. I am certainly not saying that racism is good, only that it is normal. What we do with it shows our intelligence, or lack there of.
As such I find racism to be a combination of two factors, one being our natural desire to be with what is familiar, and the other being our need to be at the top forcing us, sadly, to treat what is different in a negative way.
As a keeper of animals I try to make extra sure everybody gets food. I try to break up fights when they occur, and sometimes have sold off animals who are overly aggressive to the others. Back in school, I was a target of bullies because I stood out, and no, it was not fun. Equally I would like to think I have never bullied anyone, and find racism to be foolish, but fear that as our population grows it will only escalate as we become more and more competitive for our turn at the feed trough.