Harper Lee has led a very private life since the success of To Kill a Mockingbird. That being the case, we don't have many interviews with her we can use to better understand her source of inspiration for the book and her views on Southern society as she presents it. However, we certainly do have a little knowledge.
One thing we know is that she based the character Atticus Finch off of her own father, Amasa Coleman Lee, who married Frances Cunningham Finch. Like Atticus, A. C. Lee practiced law in Alabama. We have evidence that A. C. both tried and had knowledge of cases that inspired the story of To Kill a Mockingbird. His very first case in 1919 was defending a black man and son of murdering a white storekeeper. Like Atticus, Lee put his all into his defense but was unable to incite the all-white jury to return anything but a "guilty" verdict, resulting in the hanging of both defendants (Talmage Boston, "Who Was Atticus Finch?," State Bar of Texas).
Also during Lee's life, between 1933 and 1934, a black man named Walter Lett was put on trial whose case was very similar to Tom Robinson's. Though Lee did not act as defense attorney for this particular case, he followed the case very closely as the editor and publisher of the Monroe Journal, the town's newspaper. We can speculate that young Nelle Harper Lee learned of the case herself through the newspaper and her father. Just like Tom Robinson, Lett was accused or raping a white woman even though all evidence strongly pointed to his innocence. Also, just like Robinson, Lett was again convicted by the all-white jury and sentenced to death. Finally, just as Atticus had hoped to achieve for Robinson, Lett's case was appealed to the higher court, and his sentence was changed from execution to life imprisonment (Talmage Boston).
Based on these trials, we know that Harper Lee grew up being well-exposed to the social injustices that are a product of racism, and based on the similarities between the cases her father was involved in or had knowledge of, we are able to speculate that these racist, unjust sentences inspired her to write the book.