Atticus Finch is one of the most honorable characters in all of literature. Living in Maycomb, Alabama during the 1930s, he is raising his two young children alone following his wife's death. He throws off the societal prejudices of his town, from racism to classism, and sees people for their best possible selves. Tom is not the only struggling character whom Atticus reaches out to.
Mrs. Dubose is a generally disliked character, always spouting anger. Even when she verbally insults Atticus to Jem, Atticus defends her and forces Jem to read to her nightly following Jem's destruction of her flowers. Why? Atticus also realizes that Mrs. Dubose is battling a morphine addiction and is in withdrawal; he has a servant's heart and wants to help her, despite her tendencies to lash out at those around her.
The Cunninghams are one of the poorest families in town. Atticus understands that the Depression has hit them especially hard, and when they need his services, Atticus accepts payment in the form of crops such as hickory nuts and turnip greens.
Atticus knows that his children are watching him in every interaction, and he carefully guides them through his own words and actions. In Chapter 3, he tells Scout, "You never really understand a person until you (. . .) climb into his skin and walk around in it." Through every interaction with difficult people in town, Atticus encourages his children to see the character of people and to consider how others's life experiences have shaped their actions. So when Tom Robinson, an African American man on trial for rape, needs help, Atticus is appointed by Judge Taylor because he is Tom's best chance at a fair trial. The judge is also on Tom's side; we know this by the appointment of Atticus, known to be a strong and fair lawyer.
Atticus builds and presents a solid case for Tom, and it is clear that Tom could not have possibly committed the crimes of which he is accused. However, Atticus also understands that he has no real hope of winning the trial. He gives this advice to Scout earlier about Mrs. Dubose:
I wanted you to see what real courage is, instead of getting the idea that courage is a man with a gun in his hand. It's when you know you're licked before you begin but you begin anyway and you see it through no matter what. You rarely win, but sometimes you do.
Atticus lives the way he wants his kids to live—by serving people and showing compassion. Atticus believes in the goodness of humanity, and he has hope for a world better than the current state of Maycomb, Alabama. He wants his children to follow him in these principles and that is why he defends Tom Robinson to the best of his abilities.