Mayella Ewell is a very sad character. In many ways our hearts, as readers, go out to her. In the novel, Atticus's heart also went out to her. That said, her situation does not exculpate her from what she did to Tom Robinson. Herein lies her ethical dilemma.
She tries to seduce Tom Robinson, because she is lonely. She is lonely, because it is her responsibility to take care of her siblings without any help from her father, Bob Ewell. So, when Mayella came onto Tom Robinson, and Bob, her father came home to witness this, her father beat her severely. In light of this, Bob Ewell and Mayella need a scapegoat.
Tom, being a black man of no repute, is an easy target. So, when the trial begins, Mayella has a choice. Will she lie and frame Tom Robison or tell the truth and betray her father and undergo the shame of seducing Tom Robinson? Mayella caves into the pressure. She lies and endangers the life of an innocent man.
To give a little more context, here is what Atticus says:
“What was the evidence of her offense? Tom Robinson, a human being. She must put Tom Robinson away from her. Tom Robinson was her daily reminder of what she did. What did she do? She tempted a Negro.
"She was white, and she tempted a Negro. She did something that in our society is unspeakable: she kissed a black man. Not an old Uncle, but a strong young Negro man. No code mattered to her before she broke it, but it came crashing down on her afterwards.