The law Mayella broke was to show affection to a black man. Since she was a white woman, this was unacceptable. This is not a real law she broke, like not sending children to school. It is an unwritten social code, on her part.
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. (ch 20)
Atticus points out at the trial that the code she broke did not matter much to her before she broke it, but the consequences of breaking it mattered. She had to accuse Tom Robinson of rape because it was the only way to explain kissing Robinson. Mayella was young and naïve, and got caught up in circumstances beyond her control.