Atticus questions Mayella about her lack of friends to show that she is lonely. Mayella is stuck in the house tending the younger children. She has little company her own age and no friends to speak of. It is only natural that a lonely, battered young woman would reach out for companionship. Her lack of friends shows that Tom Robinson's side of the story is plausible. Tom says that he feels sorry for Mayella. While the townspeople do not approve of this statement, Atticus is showing why Tom feels this way by his questions towards Mayella. He is trying to provide reasonable doubt. He wants to show that perhaps Mayella is being less than truthful about the events in order to please her father and spare herself shame and embarrassment.
In Chapter 18, Mayella Ewell is called to take the stand. The prosecutor asks her to explain what had happened to her. She goes on to tell the court that Tom attacked her and raped her. When Atticus gets the chance to ask his own questions, Mayella shows a tremendous amount of anger towards Atticus. She accuses Atticus of making fun of her by calling her ma'am and Miss Mayella. The judge assures her that Atticus is just being the way he always is in the courtroom. Atticus is trying to make a point when he asks Mayella about having any friends.
"Miss Mayella," said Atticus, in spite of himself, "a nineteen-year-old girl like you must have friends. Who are your friends?"
The witness frowned as if puzzled. "Friends?"
"Yes, don't you know anyone near your age, or older, or younger? Boys and girls? Just ordinary friends?"
Mayella's hostility, which had subsided to grudging neutrality flared again. "You makin' fun o' me agin Mr. Finch?"
Atticus let her question answer his.
Atticus is trying to get the jury to see that Mayella is a young girl who was left at home with seven younger siblings to take care of, and that she was a lonely young woman. Atticus is proving that Mayella just wanted some attention, and since Tom was a willing person who good-naturedly helped her she tried to make an advance to him. The whole question about her friends proves that Mayella has no friends and wants someone to show her some kind of attention.