I'm not racist I hate everyone equally. Just kidding, racism is a learned behavior. You're either taught it or you have bad experiences with a race and just clump the whole race together, but every race has those few people that other races hate. There's a different person in ever body so treat everyone as individuals not a race. babies don't come out with hate!!
Everyone wants to feel superior to someone, that's human nature. It's also human nature to be suspicious of strangers. When someone looks different from you, it is a normal reaction to consider them (1) vaguely threatening, and (2) inferior to you. Racism is an established way to justify these irrational feelings. By pretending that an entire group of people is "inferior," you rationalize your fear of them and find someone to feel better than. It's not restricted to whites and blacks. The Japanese hold similar views on the Chinese. Look at the conflicts in Africa and Bosnia, where thousands of people that appear to us Americans as virtually identical were killed because of perceived differences. Same with the current conflict between Sunni and Shia in the Middle East. It requires rational thought to understand that these feelings have no real basis, so racism tends to be most prevalent among stupid people.
Often times it originates when members of one tribe act against members of another tribe. Since ancient times the perpetrators of these criminal acts were often captured and used as slaves, as payment for their crimes. As time passed, animosity grew between the tribes. If acts of murder were perpetrated against members of a tribe, it's not hard to see the difficulty of some to forgive.
The earliest humans were grouped by families. Any human who didn't look like the members of your own family were considered in competition for what were often scarce resources and, therefore, were seen as a threat. Then families learned they had a better chance of survival if they banded with other families and became a tribe. Still, other tribes who looked or behaved differently were seen as a threat. That was good for survival of our species at that time.
This trend of merging for survival benefits has continued into the formation of nations, yet when we encounter a person who looks or acts differently, we still have an initial and innate response to become defensive. The difference is that by now we have all figured out (or should have) that we no longer live in the days of early man, and that we have the ability to consciously over-ride that innate skepticism so society can be more inclusive, thereby reaping the benefits of shared skills and new ways to approach problems, which have continued to make life better for us all.
Bottom line: Evolution created racism, but it also created our ability to over-ride it and combat it for the betterment of all.
Racism is learned, just like language. Which means you can unlearn it - but that would require a reason to do so. It is easier to do when you live in an environment where there is a mixture of cultures (because you are constantly interacting with them) than in an environment where there is a very large majority of one culture (where you have no opportunity to interact with different cultures).