It's patently obvious that Tom Robinson isn't guilty of the rape and assault of Mayella Ewell. But this is the Deep South in the 1930s. Racial prejudice is rampant, and an African American male falsely accused of raping a white woman stands virtually no chance of getting justice. Nevertheless, Atticus has to do his damnedest to give Tom the very best defense he can provide. Although he knows full well that the members of the jury have already made up their minds as to Tom's guilt, he's still going to try and sow some deeds of reasonable doubt in their minds.
That's where Bob Ewell comes in. Everyone in Maycomb knows just what he's like—and no one likes what they see. Atticus tries to play upon the near-universal loathing that Bob inspires among the townsfolk in accusing him of beating Mayella. Her facial injuries suggest that she was attacked by someone leading with his left. Yet, as everyone with eyes can see, Tom's left hand isn't strong enough, as his whole left arm has been virtually useless since a childhood accident.
In his summing up to the jury, Atticus also makes reference to the unwritten code that he knows that they all share—that any kind of mixing between the races is strictly taboo in this deeply segregated society. So he tries to combine the predominant social view with the physical evidence written all over Mayella's face to put forward his theory of what happened. Bob Ewell attacked and beat his daughter and then tried to pin the blame on an African American, knowing full well just how offensive such an action would be in this small Southern town.