Simply put, an allegory is a story in which everything--characters, objects, places, even colors--is meant to be symbolic in order to present a deeper truth, or meaning. "Young Goodman Brown," as a moral allegory, uses overt symbolism to portray a basic story of good versus evil amidst the complications of religion and societal influence.
Consider, in this short story the first two named characters: Young Goodman Brown and his wife Faith. Symbolically speaking, Goodman Brown is meant to be an innocent and otherwise unbiased or unblemished character. Brown is neither black nor white, nor is it even a combination of both. It is neutral. His wife, Faith, in this case, represents a trust (or faith) in people, society, and the religion--or morality--of a society.
Goodman Brown takes a journey into the forest at night purportedly because he has a task to accomplish before sunrise. Symbolically speaking, this is a spiritual journey, in which the main character will not only encounter, but be tempted by the devil to walk further and further away from Faith (an intentional metaphor). The forest, as in many stories set in Puritan times, represents evil.
Of course, because this is an allegory, everything that happens, is meant to have an overt symbolic meaning. As he talks to the devil, Young Goodman Brown basically explains that as a good Christian, he really shouldn't go any further. He uses his father and grandfather's Christianity, or morality, as evidence of this. As further argument, he reveals that he could not look into the eye of his own minister and deacon should he continue to journey further down the road of temptation.
What he ultimately discovers on this spiritual journey, however, is that everyone he holds in high moral esteem (including his wife), has either made this journey before, or is actively making it that very night. The story's ambiguous culmination of the meeting in the forest is a climax that certainly leaves much room for interpretation. It is not clear whether Faith is able to resist the devil that night. Further, it is left unknown whether the entire episode was real or dreamt.
What Hawthorne ultimately accomplishes through this short story is the posing of spiritual, faith, and morality (both religious and personal) questions, and then not actually answering any of them. The use of allegory itself serves as a buffer. Readers tend to enjoy this story because the characters are mostly likable, the plot itself is straightforward, and at the surface, it comes across as very innocent. But the deeper thoughts that are clearly intentionally provoked are far from innocent. Critical readers and thinkers are left with many unanswered questions, and those who truly seek answers are doing exactly what the author intended.