Hawthorne's well-known tale is a meditation on the nature of both good and evil. Perhaps the central question posed by the narrative involves how much of either of those concepts, especially the latter, is a matter of flawed human perception rather than objective reality.
Brown meets the mysterious stranger for a purpose at first unknown to us. His wife, Faith (named with a symbolism more heavy-handed than usual in Hawthorne), wants him to stay with her, but he goes out into the night. After the visions he then experiences, he's never the same man again. The stranger shows him a picture of the negative side of humanity, including Brown's wife. Those whom Brown had believed virtuous are apparently taking part in a satanic ceremony. The vision suddenly disappears, and Brown returns to the village, now a misanthrope, convinced that all mankind are evil.
A simplistic reading of the story might conclude that Brown has now been shown the absolute truth about people. Hawthorne's actual point, however, is that it's Brown who has become evil by judging others. It is left an open question as to how much, if any, of his vision in the night was "real":
Had Goodman Brown fallen asleep in the forest, and only dreamed a wild dream of a witch-meeting?
Be it so, if you will.
In these sentences the reader is being asked the same question Brown has been confronted with. Is our perception of the negative qualities in others just perception? Is it a projection of our own moral failing if we judge others as "evil"? Is it a matter of choice as to how we view others (and view ourselves), not based on objective truth?
The answer is probably all of the above. Brown destroys his own life by accepting the proposition that everyone is a devil-worshipper, at least metaphorically. All of mankind are imperfect, and it's only by recognizing this as fact, without judging and rejecting others, that one can save oneself from the inner torment that comes to Brown.
The theme of the false perception of "evil" recurs again and again in Hawthorne. In "Ethan Brand," a man searches for the unforgivable sin, and by doing so finds that sin in his own heart. In "The Birthmark," a man becomes obsessed with a blemish on his wife's face and ends up destroying both her and himself. Even in "Rappaccini's Daughter," which on first glance seems to have a quite different theme, it is probably Giovanni's judgment of Beatrice that actually kills her rather than the "antidote" to the poison. "Young Goodman Brown" extends this false condemnation of the individual to a man's vision of a supposedly universal, fatal flaw in humanity, without realizing the flaw, like that of Ethan Brand, is in his own heart.