Lee's purpose is to demonstrate the affect that children and what they represent (innocence) can stifle a situation that could turn violent. Throughout all time, children should be protected from violence... the case is not really too true today. But during that time, these men felt the power of a child... and thereby innocence.
Scout didn't understand those men wanted to do something bad, and fortunately they wouldn't in front of her. This further demonstrates how wrong the conviction of Tom Robinson was. The children acted as a moral gauge or compass for these men. This demonstrates the contrast between the right and wrong of the entire book. That's why this timeless book is still so widely taught: these are lessons we should learn from today in our increasingly tolerant society.
One night, Scout and Jem follow Atticus down town. Atticus is standing guard outside the Maycomb Jail, making sure no one tries to attack his client, Tom Robinson. The children are just about to leave when several cars drive up. The men get out, and the children run over to see what all of the trouble is. The men warn Atticus to get his children out of there, but they refuse to listen when Atticus tells them to go home. This is when Scout recognizes Mr. Cunningham, the father of her classmate, Walter Cunningham. She starts to talk to him about things, including Walter, and asks Mr. Cunningham to tell his son that she says hello. He tells her that he will do that, and he gets the other men to disband and go home.
The night that the men go to jail the children are present. Scout’s presence serves to make the men reflect on their animal natured behavior. The men are a mob and Scout confronts them. She is the playmate and school mate of Mr. Cunningham's child. (Later the reader will learn that it is a Cunningham relative that was the only jury hold out advocating for Tom).
By having Scout present the writer is able to demonstrate another effect of prejudice, the mob. The people are acting on blind anger which is filtered by racism. Mobs were common in the south and often retaliated towards black men and boys by hanging them before they ever had a trial.