In writing To Kill a Mockingbird, Harper Lee was most probably motivated by a desire to explore some of the themes associated with growing up in a small Southern town, such as the persistence of racial prejudice, both official and unofficial. And she clearly believed that the best way of doing this was through a semi-autobiographical approach.
Had Harper Lee used a more didactic approach in her writing—that is to say, attempting to teach her readers a moral lesson—then it's likely that she would've been much less effective. For the most part, people don't take kindly to being preached at, and so if a writer has something important to say, then it's generally much better for them to do through the medium of recognizable characters with whom we can identity.
That's what Harper Lee does in To Kill a Mockingbird. She expertly presents the reader with a whole range of issues, some complex, some less so, through the lives of ordinary folk in a regular small Southern town during the Great Depression. In this way, she paints a portrait of Southern life during this period that is generally regarded as accurate and which also speaks to different people from different backgrounds and historical periods through the colorful characters depicted in the story and the universal themes with which the book deals.