Not to threadjack but I think that the most racist thing in Trek was "Code of Honor", in which the whole "black guy lusting after white woman" thing was played to the hilt.
Well, except it wasn't written that way; in the script, the Ligonians were originally reptilian aliens and the writers based them on samurai culture. The way it turned out has been blamed by some on the director, and there are anecdotes that he treated the guest actors in a racist way and got fired midway through, but the same director went on to do many episodes of In the Heat of the Night
, which seems hard to reconcile with those allegations. So at worst, there was racism injected by the director that wasn't in the script. The treatment of Genghis Khan, one of the most effective military and political leaders in the history of the world, as nothing more than a mute thug was there in the writing from the beginning.