A good lawyer, in any type of medium (television, text, movie), will do anything they can to draw out concerns regarding the character of a witness or defendant.
This is no different in the novel To Kill a Mockingbird. As a lawyer, Atticus needs the jury and judge to see what kind of person Mayella really is. Therefore, it only makes sense for him to question how she lives her life, her background, and her family.
The town knows Bob Ewell too well. They know how he feels about blacks and his extreme racial prejudices. Therefore, bringing this into court is important.
Another aspect of the questioning has to do with how Mayella lives her life. The fact that she has been known to flirt can bring doubt into the minds of the jury. If the jury can see that Mayella could have attempted to seduce Tom, the jury could then have some doubt as to how things happened exactly.