Hawthorne uses irony to develop the theme that Puritan society was hypocritical.
This is because in the text he presents Goodman Brown, as the protagonist, who lived in a Puritan society presented as holy and full of whole, religious and pure people, turned to the church and the will of God. However, it was necessary for Goodman Brown to meet the devil himself, who showed him how that society was more friendly to him than to God, because when nobody saw him, they behaved in a completely vile and sinful way.