Ironically, because he feels like such a sinner, Dimesdale's sermons become more fiery and effective. In addition, people believe he is holy because many times on the pulpit he confesses that is the worst of sinners. What he always plans on doing is going on and confessing he is the father of Pearl. But, he never does. So people assume that if such a good man thinks he is an awful sinner, he must be some kind of saint. His self-torture includes all night prayer vigils, fasting obsessively, and flogging (or hitting) himself with a whip. Of course, these forms of physical torture cannot curse a malady that is basically psychological and caused by guilt. The only cure for that is to confess his guilt to his congregation. Unfortunately, Dimmesdale loves the admiration of the people and cannot bring himself to do the one thing that would free his conscious.
Dimmsdale, being a good minister and a man of God, tortures himself physically and emotionally. He does this because he has crossed the line with a married woman, obviously a forbidden thing to do. Because he is supposed to be the example of virtuous behavior, he feels the need to torture himself to punish himself for the sins he has committed.
Dimmesdale is a good minister b/c even though he crossed the lines with a married woman he continued to try and be a better man in gods eyes.