The Ewells know that they are the lowest of the low amongst the whites in Maycomb. They have no money, no education, and no breeding. The single thing that elevates them at any level in the community is the fact that they're white. Like most people in similar situations, Bob and Mayella would like to better their station in life. However, Bob is unwilling to put forth the effort necessary to change his family's lot and Mayella doesn't have the resources to change her own life.
With her mother dead, Mayella becomes a surrogate wife for her father and mother for her younger siblings. The fact that Mayella wants a better life for herself is evidenced by the red geraniums she grows so lovingly — they're the only sign of beauty in a dismal, filthy shack and yard. She can't attend school because she has to take care of her younger siblings, especially when her father leaves on days-long drinking binges. She's involved in an incestuous and abusive relationship, but she doesn't have anywhere to go or anyone to help her. At 19, her future is set. She will most likely stay with her family, continuing to be both sexually and physically abused, until she marries and starts the cycle anew.
The idea of having an affair with a black man is exciting in a dangerous sort of way, but more importantly, making advances toward Tom gives Mayella power. This completely powerless woman has total control over Tom in this situation. If he were to agree to a liaison with her, then he would remain at her beck and call for the rest of his life. Readers know what happened when he didn't agree.
In an attempt to gain some power in a shabby, pitiful existence, Mayella costs a man his life. Ironically, when Atticus finally shows Mayella the respect she so craves, she accuses him of making fun of her and ultimately refuses to answer his questions.
Bob Ewell would also like to improve his family's station, but the fact that "he was the only man [Scout] ever heard of who was fired from the WPA for laziness" proves that he isn't willing to earn it. Ewell is a drunkard and an abuser who is despised throughout the community, and very likely by his own family. But in accusing Tom Robinson, he sees what he believes is a brass ring. In his mind, the town should think him a hero for saving Maycomb's white women from a "dangerous" black man. Defending his daughter by going to court should raise his family's stature. If they don't gain more respect from the community, at least Bob won't have to live with talk in the black community about a white woman making a play for a married black man. Unfortunately, all of Ewell's plans backfire. By the end of the trial, he and his daughter are proven liars, he's been publicly identified as a sexually and physically abusive father who fails to provide for his family, and the entire town knows that Mayella made sexual overtures toward Tom. Instead of improving his life, Ewell cements his family's horrible reputation once and for all.
In this situation, Bob Ewell can do little but try to recover his own pride. He makes good on his threats to harm the people who embarrassed him in court. He rejoices in Tom's death. Bob Ewell is the kind of person who actually seems to enjoy being despicable.