First of all, to address your question, you must understand that in this day, Negroes were thought of as lesser. Relationships, particularly romantic ones, were a taboo of society. When Tom suggests that Mayella was the one who made an advance toward him, he immediately (although respectfully and truthfully) degrades her in front of the entire town. Gilmer can't believe that Tom would do such a thing, it was not his place to get to say such a thing. But this was a court of law and Tom should be able to tell the truth on the witness stand.
This was a common attitude in the 30s. Today, in the American society, romantic relationships see very little bias according to race.