"Young Goodman Brown" by Nathaniel Hawthorne is set in Salem, Massachusetts, at about the time of the notorious Salem Witch Trials. What that means, of course, is that the prevailing religion in this story is Puritanism.
While those who called themselves Puritans desired to live holier lives, closer to God in a community where they were free to worship, certain problems ensued. First, they believed that they had to live pure (sinless) lives because they had no way of knowing if they were among God's Elect (chosen people). This, of course, was an impossible task, since humans sin. All of them.
Second, in this theistic society, sins were treated as crimes and people who sinned were punished as criminals. This practice, rather than promoting an environment of sinlessness, eventually caused people to call out (snitch on) other people's sins in an attempt to divert attention from or hide their own sins, in addition to their desire to rid their town of sin. The severity of the punishments for sin also drove people to hide their sins. Symbolically, the forest was the place where people met the devil; it was a place where their true selves were on display.
In this story, Goodman Brown goes to the forest to test his faith, and he sees all the people--including his beloved wife, Faith--cavorting there with the devil. After he returns home, whether this was a dream or real, Goodman Brown is changed by this experience.
On the Sabbath-day, when the congregation were singing a holy psalm, he could not listen, because an anthem of sin rushed loudly upon his ear, and drowned all the blessed strain. When the minister spoke from the pulpit, with power and fervid eloquence, and with his hand on the open Bible, of the sacred truths of our religion, and of saint-like lives and triumphant deaths, and of future bliss or misery unutterable, then did Goodman Brown turn pale, dreading lest the roof should thunder down upon the gray blasphemer and his hearers.
The same people Goodman Brown saw dancing and partying with the devil in the forest are church members who live as if they are pious and holy. It is just to much for the man and he loses his faith; ultimately, this same kind of disillusionment is what causes Puritanism to fade away.