Harper Lee wants readers to understand that Mayella is not a monster; she is young and uneducated, and trapped in a situation she cannot control.
It is easy to demonize Mayella Ewell. She accuses Tom Robinson of rape, and we know that he was just trying to help her. However, Lee does not want us just look at her as the perpetrator of a terrible miscarriage of justice. She is also a victim.
Our first introduction to Mayella is through her flowers.
Against the fence, in a line, were six chipped-enamel slop jars holding brilliant red geraniums, cared for as tenderly as if they belonged to Miss Maudie Atkinson, had Miss Maudie deigned to permit a geranium on her premises. People said they were Mayella Ewell's. (ch 17)
The flowers give us a specific view of Mayella. She is the one spot of light in a dismal setting. She attempts to bring beauty into her life in whatever minor way she can. Scout is already beginning to feel sorry for her.
As Tom Robinson gave his testimony, it came to me that Mayella Ewell must have been the loneliest person in the world. She was even lonelier than Boo Radley, who had not been out of the house in twenty-five years. (ch 19)
We see that Mayella is in many ways just as cruelly treated. Hers is a sad story. Atticus is aware of this. Despite his attempts to show the truth about her on the stand, he also pities her.
"She was white, and she tempted a Negro. She did something that in our society is unspeakable: she kissed a black man. … No code mattered to her before she broke it, but it came crashing down on her afterwards. (ch 20)
The irony is that Mayella had to turn on the one person who cared about her and was trying to help her, in whatever small way. She never intended to hurt him, but she ended up in over her head, and things got out of her control pretty quickly. Lee wants us to understand this about her. It does not excuse her of responsibility, but it does help explain her actions.