This is an excellent question, and I believe it lies at the heart of Lee's message in the story.
There is no doubt that Harper Lee's To Kill a Mockingbird is an icon amid American Literature. Her characters are admirable and/or memorable, but her messages, and there are several, touch on the true fabric of society, even of humanity.
As a reader, we are struck by the unfairness and lack of justice in the case of Tom Robinson. Here is a man whose life has been difficult in a variety of ways: he lost the use of his arm in a cotton gin accident, has been in jail for getting into a fight (and not having the money to pay the fine), works hard to support his family, and lives in a community that sees him as less than human. His only "sin" is that he takes the time to be kind to Mayella Ewell, and she becomes the tool of his destruction.
It is unfair that Tom is accused by Bob Ewell: Ewell's biggest problem is not that Tom was in the house. Bob Ewell knows that Mayella was at fault in this situation, but even while he calls her a whore, his contempt for her actions and Tom Robinson's skin color become melded as one. Ewell accuses Tom for three reasons: he is angry at his daughter, he hates the blacks, and he is personally mortified that his daughter has been found in a compromising position.
(If we read between the lines, it seems that Bob Ewell may have sexually abused Mayella:
She says she never kissed a grown man before...She says what her papa do to her don't count.
In that there is not a loving or gentle bone in Bob Ewell's body, a father-daughter kiss seems unlikely.)
Tom Robinson is found guilty of something he did not do. The prison guards shoot Tom seventeen times in the back as he tries to climb the prison fence (with only one good arm). These instances are neither fair nor just.
Boo Radley's treatment at the hands of his father is not fair or just. Though Boo (Arthur) started out as simply a typical teenager who got into a little trouble, his father takes it as a personal affront (much like Bob Ewell), and punishes his son. He allows him to be left in the jail for an excessively long time. When ordered to remove Boo from the jail, Mr. Radley imprisons his son at home, and abuses him until he is a shadow of the person he was. This is terribly unfair and unjust.
However, we do find justice in the story. We see if first when Boo Radley saves the children, killing Bob Ewell in the process. Ewell is evil personified. If it were not enough to glean some personal satisfaction with Tom's conviction, and ultimately his death, this drunken, lying, abusive, socially reprehensible man attacks the innocents: Atticus' children Jem and Scout. Justice is served to Bob Ewell at the unlikely, gentle hands of Boo Radley.
Next, when Heck Tate realizes that Boo has killed Ewell (not Jem, as Atticus suspects), justice and fairness come together. Boo has saved the children's lives. Tate knows that in light of what Boo has dealt with in his life, sending him to jail would be wrong. Justice is served in that Ewell can no longer hurt anyone else, and it is only fair to Boo that he is not linked to the tragedy. No one is harmed in releasing the story that Ewell drunkenly fell on his knife—a knife which he tried to use on Jem and Scout.
Lee shows us the frustrating lack of fairness and justice in several situations in the story, but allows us as readers to witness what is both fair and just in the end.
Justice and fairness are, indeed, related in Harper Lee's novel, To Kill a Mockingbird. In fact, the words are synonymous, according to Miriam Webster:
justice - equitableness (fairness), moral rightness
fair - free from injustice
There are several motifs that thread through Lee's narrative. The prevalent one is considering things from others' points of view, a moral precept that Atticus seeks to instill in his children. In his efforts to have the children be understanding, he has them stop mocking Boo Radley, be kind to poor Walter Cunningham, read to Mrs. Dubose despite her insults, be polite and respectful to Aunt Alexandra and Calpurnia, and even to feel sorry for Mayella Ewell and understand Bob Ewell.
This fair treatment certainly translates into the legal world of the courtroom. Bob Ewell and Mayella are treated politely and fairly as they testify at the trial of Tom Robinson despite the false charges made by these Ewells. In his closing argument Atticus underlines the theme of moral rightness in the novel:
...there is one way in this country in which all men are created equal--there is one human institution that makes a pauper the equal of a Rockeffeller, the stupid man the equal of an Einstein, and the ignorant man the equal of any college president. That institution, gentlemen, is a court....our courts are the great levelers, and in our courts all men are created equal.
Bob Ewell may have gotten away with perjury, but he is served poetic justice when he dies at the defending hands of Boo Radley.