The epigraph of the novel – the first real text we see after the title – points us to the importance of forgiveness (check out our section on "What's Up With the Epigraph?" for more on this). The most transformative moments of both Dolly and Karenin's lives come when they can forgive their sinning spouses. In Anna Karenina, forgiveness is less about the person who's forgiven and more about the one who's doing the forgiving. Forgiveness, especially in Karenin's case, is associated with communion with God and greatness of spirit. Once Karenin's jealousy and resentment of Anna start to creep back in, he's diminished as a character.
Dolly shows the most compassion for Anna because she can understand why Anna made the choice to run away with Vronsky.
Karenin's forgiveness of Anna during her illness is sincere – and its very sincerity is what causes Anna so much torment. If Karenin had never forgiven her, she would have found it much easier to leave him.