This is a story about Young Goodman Brown losing his faith in goodness and in humanity. Brown adheres to an old Puritanical religious fundamentalism. In such a belief system, moral and ethical codes are very strict. When Brown starts on his journey, he is full of hope and faith. He believes that people are good or bad, no in between. But as he sees the church elders and supposedly pious people of his town consorting with the devil and attending a witch-meeting, he loses faith in humanity. Brown can not accept that good people can be capable of sin.
Brown will not accept that supposedly good people would consort with criminals and disreputable people. One could interpret this story as a very pious man realizing the presence of evil in the world. But the story is also a subtle criticism of strict religious beliefs which instill in someone like Brown the idea that a person is either wholly good or wholly evil. This is a very "black and white" view of the world and is impractical and unfairly judgmental.
In recognizing that anyone is capable of evil (as much as they are capable of good), Brown loses his faith in humanity. Rather than accepting the fact that people are fallible, Brown rejects humanity.
When Brown loses his faith in humanity, he also loses his faith in Faith. After seeing saints and sinners together, and his wife Faith in the midst of all this "deviltry," Brown gives up his belief in the power of goodness and acknowledges that "Evil is the nature of mankind."
"My Faith is gone!" cried he, after one stupefied moment. "There is no good on earth; and sin is but a name. Come, devil! for to thee is the world given."