Atticus has a genuine respect for the people around him, even when their behavior perhaps does not justify his high regard. The reason he thinks so highly of Mrs. Dubose, he tells the kids, is that she could have continued with her morphine to keep herself comfortable as she died, but she was adamant that she would "leave this world beholden to nothing and nobody". Because Atticus has such admiration for a woman as stubborn and determined as Mrs. Dubose, it is completely consistent with his character that he would defend Tom Robinson; like Mrs. Dubose, Atticus is not one to shy away from a fight, even if it becomes unpleasant. He knows the road ahead is going to be difficult, long before the trial even begins, warning Scout and Jem to remember that regardless of what the townspeople say about Atticus, Tom Robinson, and the case, the Finches will still consider them friends.
Although Atticus is loyal to his friends, the people of Maycomb, he is absolutely determined that he will give Tom Robinson the best defense he possibly can, and on the topic of people falsely accusing and taking advantage of people who are black, he does not mince words. While the term "trash" is freely thrown about Maycomb to describe nearly anyone who doesn't fit into the narrow definition of non-trash that the people have established, Atticus doesn't normally use that term, except when he tells Scout and Jem the following:
As you grow older, you’ll see white men cheat black men every day of your life, but let me tell you something and don’t you forget it—whenever a white man does that to a black man, no matter who he is, how rich he is, or how fine a family he comes from, that white man is trash.