This is a much-asked question concerning this short story, as Hawthorne deliberately leaves it unspecified as to whether Goodman Brown dreams what he sees as he takes his walk into the woods, or whether it was actually something that really occurred. The sudden way in which Goodman Brown is shifted from a scene where he is imploring his wife, Faith, to remain true to God and then is alone by himself in the woods, "amid calm night and solitude," only able to listen to the noise of the wind as it dies down in the woods, either suggests a very strong dream or magic of some description.
However, it is clear that Hawthorne's focus was not on whether the events actually occurred or not: his intention was to show the impact that Goodman Brown's vision of the evil within all humanity has on him, and how it turns him into a rather bitter and depressing individual. Note that when the narrator asks precisely this question, he responds that "if you will" it to be a dream you can, but:
...it was a dream of evil omen for young Goodman Brown. A stern, a sad, a darkly meditative, a distrustful, if not a desperate man did he become from the night of that fearful dream.
Dream or reality in a sense does not really matter. What does matter is the way that this night changed Goodman Brown for the worse and how it impacted the rest of his life. The importance of what Goodman Brown lies not in whether it was a dream or reality, but the truth that it showed him about the capacity within us all to commit evil acts, no matter how "good" we may ostensibly be.