The mistake that Tom made was feeling sorry for a white woman, when whites are supposed to be superior to blacks.
By feeling sorry for Mayella, Tom put himself above her. This is the ultimate mistake for a black man in a town like Maycomb. No matter what, whites are superior to blacks. This is the way they want to keep things. Even the poor whites that live in trash heaps like the Ewells are better than respectable, hard-working Tom Robinson.
Atticus is one of the few people who looks at Tom as a person. He is fully aware that Mayella Ewell was not raped. She was beaten up by her father because she kissed a black man. He is aware that Tom Robinson did nothing wrong except try to help Mayella. It was Mayella who crossed a line, not Tom.
During his cross-examination, Mr. Gilmer makes a huge victory when he traps Tom Robinson into saying he felt sorry for Mayella. By that point, everyone felt sorry for her. Even Scout realizes she is the loneliest person in the world, and can empathize with her despite the misery she has put the Finch family through with her false accusation.
The witness realized his mistake and shifted uncomfortably in the chair. But the damage was done. Below us, nobody liked Tom Robinson's answer. Mr. Gilmer paused a long time to let it sink in. (ch 19)
Mr. Gilmer makes the most of this victory by reinforcing Tom’s low status, raising his own voice and referring to Tom as “boy.” Sadly, this is enough to convict Tom Robinson of a crime he did not commit.
Atticus was able to establish that Tom was not guilty of raping, or even hurting, Mayella Ewell. This is why he got the jury to deliberate as long as it did. However, Tom saying he was sorry for Mayella made him guilty of another crime, feeling sorry for a white woman, which in the eyes of the jury was enough to convict him of the one he did not commit.
The social system of Maycomb doesn't allow for Tom to take pity on Mayella, even if she is derserving. This is because the Ewells, even though they are dirty and sad and inwardly ugly, believe they are superior to Tom and anyone with black skin, and they take it as an insult for someone they believe to be subhuman to take pity on them.