The sociological and historical issues raised by your question are the subject of very lively academic debate right now.
Broadly speaking, there are two camps. One sees racism as a modern, western invention emerging from the late 18thC into the 19thC; classical antiquity and the pre-modern period in general are considered to be pre-racism. This is what I would call the 'standard account'. The opposing position has only gained traction in the past 10 years or so; this camp maintain that the scientific racisms of the modern period are directly related to the proto-racist structures of the Ancient world.
Addressing social acceptability : group discrimination and domination on the basis of 'race' (which, remember, is a biological fiction) is the historical norm, not the exception. There are historical moments in which racism was opposed and attacked, but they are few and even these did not involve all strata of society.
One example is the French Revolution. The abolition of slavery under the Revolution in 1794 included emancipation and, generally, the principle of nondiscriminatory racial equality. The Revolution failed, Napoleon reinstated slavery in 1802 and it wasn't abolished again until 1815. Emancipation didn't happen until 1848 and equal rights? They were always guaranteed by the Rights of Man and the Citizen, but antidiscrimination laws weren't passed until 1972.
Kind of a depressing answer, but finding any point in history - even recent history - when racism has been considered universally unacceptable by all strata of society is actually quite difficult. If you want to split hairs, different logics of racism have come and gone, but racial discrimination has very much been the standard.
Sources :
Charles W Mills, The Racial Contract. Ithaca : Cornell University Press, 2007.
Finally, I highly recommend Ta-Nehisi Coates' recent and very important cover story for the Atlantic Magazine : 'The Case for Reparations'. Every American should read every word of this.
Disclaimer : I study racial domination as exercised by European colonial powers and as a facet of contemporary neo-imperialism; my response reflects that. It would be really great to hear from some non-western specialists on the social acceptability and historical construction of racism in non-white contexts.
For some reason, I've given a fairly extensive, though at times meandering, answer:
The first thing to say is that racism, as we would define it, does not exist at all until the early modern era, certainly not before 1400. Let me say that again: racism is a concept of the modern world, and cannot be said to exist in the medieval world or before.
Most historians of racism agree on this point and often date racism--which we might define as the systematic discrimination of a people because of perceived physical differences (Note "physical differences": see how, upon reflection, racism is almost a scientific idea?)--to the spanish inquisition in the early 1500's.
After the Spanish expulsion of Jews in 1492, Jews who had stayed and converted to Christianity were tortured until they admitted that they really were still Jewish. Note here that if you can convert, it's not racism. (For the Nazis it didn't matter what you said, Jewishness was a physical condition.)
That being said, I would argue that from the moment of racism's emergence, it was always controversial. There were always significant numbers of people who saw racism and the various institutions to which it gave existance (e.g. slavery) as fundamentally wrong and evil.
Of course, racism is also a method for those in power to maintain power (certainly oppression and slavery may be a basic feature of human civilization, just not racism) and as such, history gives us a much clearer view of the racists than it does of those who spoke against it. It was socially unacceptable to be racist, in other words, among communities which rejected, in one way or another, political or economic pursuits. It was unacceptable among certain groups of the very religious (the puritans,) of the philosophically minded (Rousseau,) as well as among many artistic types (think Shakespeare's Othello.)
Finally, it's worth pointing out that even among the racists, there were many who understood the evils of racism, yet found themselves enmeshed in the institutions that preserved it. For example, the slave owning founding father, Patrick Henry of Virginia, wrote a letter in 1763 explaining why he continued to suppress what he knew to be “the natural rights” of his slaves. He wrote, “Would any one believe that I am Master of Slaves of my own purchase! I am drawn along by [the] general inconvenience of living without them, I will not, I cannot justify it. However culpable my Conduct, I will so far pay my devoir to Virtue.”