I can't tell you exactly how it was formed, but I can give you some history on how it might have come to be.
There are many times throughout history that we see other countries coming into other countries that are uncivilized (or so they thought) and have people living there that had different beliefs or different ways of living. In the 16th century, Europe came into America/Mexico and began pushing their religion/ways of life on the people who were there because they beleieved them to be "uncivilized" and "uneducated" when in reality, they had an education system where everyone was educated and their law system was in place. These people began rejected the European way of life and were tortured, killed, raped and taken as slaves for it. This could possibly be where it began as it put a bad image on "coloured" or "different" people. They wre labeled savages.
It could have also began because people in European societies didn't like different things. They were all very much the same in the aspects of religion, ways of life and situations that they were in because they're neighbors were all the same. When people would come back from other new lands and proclaim that they found uncivilized, uneducated savages there, and they were defined because of their colour of skin, that would put a bad rep on them also and it would pass down from one generation to another in families and therefore, racism would start and continue.
I don't know if this helped because it was posted a while ago...but I hope it did something.
Racial discrimination is formed by one race deeming themselves better or above another race.
Racial discrimination has existed since the time that more than one culture interacted with one another. By examining any of the ancient civilizations, it can be seen how one race would discriminate against another. For example, the Ancient Egyptians (not by any means the first culture of Earth, but a good example, none the less) discriminated against the Middle Eastern people from regions we now know as the "Middle East", or Israel, Iran, Iraq, etc. During the time of the Ancient Egyptian rule, the people of the Middle East were finding themselves invaded by the expanding Egyptian rule. As the Egyptians invaded and found this culture based on Judaism, they found it lower than their own and enslaved them. The Egyptians took the Jews they captured back to Egypt and these people were forced into a slavery form.
To look at another form of racial discrimination, we can look at the various groups of any of the ancient countries in general. THe other user choose to use Asia, specifically China, so I will look at the European heirarchy. In the early days of Europe, it is well known and understood there was a class system that had the monarchies at the top, followed by the nobles, then the peasantry, and lastly the servants. While some may argue this is not a racial discrimination, in a since it is. During these times, a peasant may well have had yellow skin and orange eyes when compared to a noble. The class systems were very stiffly defined and it was extremely difficult for upward mobility, although not fully impossible. This is a good time to point out that racial discrimination is not nearly as concrete as we would believe. In any and every culture, a person of the discriminated race would be fully able to gain a status percieved as above them simply by doing something unique. Look at people such as Fredrick Douglass or MOses even. These people were part of the minority but still rose to gain respect.
Racial discrimination is an aspect of human culture. It seems to be as natural as breathing to humans that we should deem one ethnic group or race as being above or below another. As saddening as it is, it can be found back into the earliest days.
*all this information came from history texts I have from my history major in education. One is the HIstory of Africa and the other is a book on World Civilization.