This is a great question that shows the problem of mankind. We almost have to endure setbacks and problems to learn.
Lee shows this in the characters of both Jem and Scout. Scout has great problem with Walter, but after punishment by Calpurnia, a situation at the jail with Mr. Walter Cunningham, and talks with her dad about the state of the economy, she comes to understand that farmers struggled significantly during the Dust Bowl of the Great Depression. Jem wanted to have great problems with Mrs. Dubose, but Atticus used her as an example to show that people are more than we see in passing. Sometimes they have pain that is unexplained to the naked eye.
Through each character that Jem and Scout encounter, Atticus or Maudie reveals their truth of circumstance. Once the layers of ignorance and rumor are peeled away (for example take Boo), the children learn valuable lessons about humanity. Scout most clearly emphasizes this in the last chapter when she looks at the world through his eyes.
Why does Lee construct her novel in this manner to help characters reveal truth and humanity after ignorance and rumor? I think this has much to do with society in the 60s beginning to accept black folks as peers. Lee wanted to encourage this to happen on a large scale. This was truly a purpose that applies to all generations as we find other people groups to isolate. She encourages inclusion.