Tom Robinson was probably the only person who was decent to Mayella.
Unfortunately the ideas about race and society held at the time meant that contact between them could never be anything other than distant and respectful. But Mayella's yearning for some form of close human contact emerges during the trial. She had saved for almost a year to have enough nickels to give her brothers and sisters a treat in order to have her house empty when she invited Tom inside. When she made her advance to Tom he was caught by his inability to hit a white woman and the extreme taboo that Maycomb placed on any form of sexual contact. He had no choice but to run from Mayella when he got the chance. Unfortunately for Tom the chance came with the arrival of Bob Ewell at the window.
The trial itself provides Harper Lee with the opportunity to examine the attitudes of people like the Ewells and the presumably more respectable members of the jury. Bob Ewell emerges as a drunken, bullying, child-abuser with little respect for the law and even less for truth and justice. But however low in the social order he is, Bob Ewell can still look down on black people. At the beginning of his testimony he complains about a 'nest' of them near him bringing down the property values of his shack by the town dump. Tom's account of Mayella's actions suggests that he may have indulged in some form of incest with his daughter, but the taboo against relationships between white women and black men is so strong that even Bob Ewell is shocked and horrified by it. He responds first by savagely beating his daughter and then by accusing Tom Robinson of rape.
Whatever respect or sympathy the reader might have had for Bob Ewell is dispelled by his behaviour in the courtroom and the evidence that Atticus produces that he was the cause of Mayella's beating. Not only is he a self-righteous bully but he is prepared to sacrifice Tom Robinson's life for his own selfish ends. The reader is more likely to feel sympathy for Mayella as the trial progresses. Her loneliness and need for simple human contact are made painfully evident as Scout comes to understand that she is 'the loneliest person in the world', rejected by white people because of her poverty and unable to mix with Negroes because she is white. The causes of her behaviour are made clear and Maycomb's social and racial prejudice have a large part of the blame.
In his summing up, Atticus explains her accusation of rape in terms of guilt. She has committed no crime, she has merely broken a rigid and time-honoured code of our society, a code so severe that whoever breaks it is hounded from our midst as unfit to live with. Atticus says explicitly that she is 'the victim of cruel poverty and ignorance' but he cannot condone her actions because her solution involves 'putting away the evidence' and that evidence is the life of a human being.
Tom Robinson's innocence is established to Jem's satisfaction at least, but the success of Atticus's case is measured only in the unusual amount of time the jury spend before bringing in a guilty verdict. The explicit racism of the trial process is acknowledged by Atticus when he speaks of Bob and Mayella presenting themselves to the court
in the cynical confidence that their testimony would not be doubted, confident that (the jury) would go along with them on the assumption - the evil assumption - that all Negroes lie.
Mayella herself expresses the same idea in her outburst at the end of her testimony, when she says that the gentlemen of the jury are 'yellow stinkin' cowards' if they don't accept her version of the facts. Maycomb's racism is so deep in such matters that Tom is lucky not to have been lynched without a trial at all.
It seems possible however that the evidence presented by Atticus could have swayed the jury if it had not been for one simple mistake made by Tom Robinson in giving his evidence. In his account under cross-examination by Mr Gilmer of his relationship with Mayella Tom says
'Yes suh. I felt right sorry for her, she seemed to try more than the rest of 'em - '
Mr Gilmer picks up on this and Tom 'realized his mistake' and 'the damage was done'. Tom's crime in other words is not that he was kissed by a lonely white girl but that he felt sorry for her. By taking pity on a white person Tom is breaking a fundamental rule of racial superiority. Bob Ewell is not the only white person who needs black people to look down on. Even Mr Gilmer is so insulting in his attitude to Tom that Dill has to leave the courtroom in tears. Atticus tries to undo the damage caused by Tom's mistake in his summing up but it is probably this statement that affects his case most severely.
The advantage of using a court case to highlight attitudes is that the legal process requires everything to be as explicit as possible. Views and behaviours that would normally be understood by the majority of adults have to be put into simple enough language for a child to understand them. The advantage of having the trial narrated by Scout is that her childish understanding is free of adult prejudice and expectations. She and Jem measure the proceedings against simple child-like ideas of truth and justice and find them grossly wanting. On the other hand Jem is an expert on court behaviour from watching her father on other occasions so she is able to give an insightful account into most aspects of the trial.
In conclusion, To Kill a Mockingbird reveals that law and justice is in order but justice is not given to its people because of the corrupt and divided society the people of Maycomb live in. After the events of The Tom Robinson case shows the ugliness of both racial and social prejudice. Ultimately the jurors choose to vote along racial lines without regard for truth or justice. Mayella and Tom are both victims of Maycomb's prejudice but only Tom has to pay. However, Atticus’ strict belief in equality and giving people a second chance, has led Maycomb to become a better place, where black people are now being treated as equals.