As many of us may know, Alabama -where TKAM was set- has a long history of racism.
There was an 1883 court case Pace v. Alabama in which Supreme Court unanimously ruled that state-level bans on interracial marriage didn't violate the 14th Amendment. If you didn't know off the top of your head, the fourteenth ensures the right to be free from discrimination in states aka equal protection of the law. The Pace ruling will hold for more than 80 years and wouldn't be overturned until McLaughlin v FL in 1964, a case where an interracial couple was jailed and fined. They then went back to court and got exonerated, which overturned the Pace decision.
So, technically, what Mayella did was illegal, because it violated Alabama's anti-miscegenation statute.
Even though many northern states such as Massachusetts or Maryland had gotten rid of these laws by the late 1800's, at the time that TKAM takes place, there were plenty of instances where southerners tried to revise the Constitution in order to ban interracial marriage in all 50 states (Roddenbery, [D-GA]; the Cable Act; Blease [D-SC]).
It's important to understand what the Pace case was all about because the couple charged was very similar to that of Mayella and Tom Robinson. The plaintiff, Tony Pace, an African-American man, and Mary Cox, a white woman, were residents of Alabama. They were arrested because they were in a sexual relationship. (important to note that they weren't married, just together) They were charged with adultery and fornication and both sentenced to 2 years in the state penitentiary. Marriage, co-living, and sexual relationships between whites and african-americans were all illegal in AL. Interracial marital sex was deemed a misdemeanor, because the couple got married under the jurisdiction of some other state that allowed that, whereas extramarital sex was a felony. Because of the criminalization of interracial relationships, they were penalized more severely for their extramarital relationship than a white or a black married couple would have been.
In the infamous case Powell v Alabama, young white women accused black men of raping them in order to avoid legal repercussions. Even though these women were looked at differently, they were treated with sympathy, as opposed to the disgusted looks and alienation they got once it was revealed that the interracial sex was consensual.
Mayella was probably in the same mindset, she figured that she would rather garner sympathy from the public than be treated like a pariah -and possibly face jail time- in the intensely racist community that she lived in.
It is largely assumed Harper took inspiration from the real life case of the Scottsboro Nine, which /u/norepinepherine references but does not go into detail on.
In March 1931, nine African American young men, ages 13-19, were arrested on a train going to Memphis outside the town of Paint Rock, AL. They were initially charged with creating a ruckus on board, but when officials emptied the train cars, they discovered two white women who were hitching a free ride. Hobo-ing was a common practice, but also illegal at the time. The women did not want to be prosecuted, so one immediately claimed she had been raped by the nine black youths, and the other agreed (though Ruby Bates later recanted. Victoria Price, the first one, went to her grave sticking to her story). The nine young men (who didn't know each other, except two who were brothers), were taken to jail in the local town of Scottsboro, AL.
After a farce of trial, in which there was no evidence presented, eight of the boys were sentenced to death, one to life imprisonment (only because he was under-aged). The International Labor Defense (communist-affiliated, but not officially communist) took up the defense of the Scottsboro Nine, which they were called, and started an international campaign to save their lives. The communists were very involved, but so were middle and upper-class black community members. Churches, fraternal organizations, politicians, and all political parties could rally behind the Scottsboro Nine because the case was so blatantly unjust.
In 1937, four of the young men were released. It wasn't until 1946 that the last of the "boys" was released. It wasn't until 2013 that all the men were pardoned or absolved of the crime, showing just how much influence white women's accusations of rape carried in the Jim Crow South.
The young men, because we tend to forget their names, were Olen Montgomery, Clarence Norris, Haywood Patterson, Ozie Powell, Willie Roberson, Charlie Weems, Eugene Williams, and Andy and Roy Wright.
The best account of the Scottsboro case is Dan Larson's 1969 Scottsboro: A Tragedy in the American South, however, I would argue much more work needs to be done regarding, specifically in relation to the international hype around the case, the communist influence, and the role of gender.
AMA about Scottsboro
I just finished the book. And I don't see an answer to your questions in the responses so I'll give you my take. Mayella was caught by her father making advances at Tom Robinson. Her father beat her. He then decided to get her to lie about the circumstances of the interaction of Tom and herself, and what the fall out was afterward.