The novel's historical context is the Great Depression era of the 1930s, in which racism reigned supreme in the deep South, where the story is set. At that time, southern whites were determined to uphold an ideology of white supremacy and were supported by a political and judicial system run solely by whites for the benefits of whites. The system was weighted and distorted by unspoken rules about how justice operated.
The novel shows two codes of "justice" coming into conflict. The first is based on the false ideology of the absolute infallibility of white supremacy: the superiority of whites in all cases had to be upheld as proof that white, are indeed, always right. This meant, in the context of the novel, that as soon as Mayella Ewell, a white, accused Tom Robinson, a black, of rape, her word had to be held as inviolable.
Atticus, however, adheres to a different concept of justice, one that is colorblind. His notion of justice is evidence based, and the evidence shows that Tom Robinson could not have raped Mayella. He therefore works from a different set of premises, one that puts him at odds with almost all of his neighbors.
The book illustrates how difficult it is to achieve an impartial system of justice in a political and social context in which preserving injustice is seen as imperative by the people benefitting from the injustice.