What do you think Hawthorne gains (or loses) by the last sentence of "Young Goodman Brown?"
Some critics remark that Hawthorne is criticizing Puritanical-Calvinism. Calvinism is known for being quite critical of the human race. Calvinism teaches that people are inherently depraved and require God's grace to redeem and/or save them and their souls. When Young Goodman Brown "loses his faith," he has lost faith in the possibility that people (notably, his fellow townspeople) can even be so redeemed. Thus, he spends the rest of his life perceiving everyone as inherently depraved and sinful. He's lost faith in them, in himself, and in the idea of faith itself.
Another way to look at this is in broader terms, but still a criticism of religious fundamentalism. Brown loses faith and hope in humanity, not necessarily because the doctrines of his faith (Puritan or Calvinist) have failed him but, because he can not accept that people can do good and evil things and still have the innate capacity for good. In this analysis, if we consider or guess what Hawthorne's intent is/was, Hawthorne was criticizing religious fundamentalism and/or he was criticizing people who are so self-righteous or single-minded that they can not recognize that people are inherently dualistic: capable of good and evil.
Other than these criticisms and guesses as to Hawthorne's specific intent, we might say that he gains a glimmer of hope in the last few lines. Young Goodman Brown has lost all hope. But since Hawthorne highlights Brown's stubbornness, he seems to suggest that a less stubborn perspective, a less stubborn person, could understand the duality of humanity and strive for goodness even though there is evil in the world.
Often, awaking suddenly at midnight, he shrank from the bosom of Faith; and at morning or eventide, when the family knelt down at prayer, he scowled and muttered to himself, and gazed sternly at his wife, and turned away.
With an attitude like this, Brown is never going to entertain the idea that his religious doctrine was too strict or that he can see salvation in a world where good and evil are equally present. In what seems like a hopeless ending, Hawthorne suggests hope subtly by pointing out how stubborn Brown had become. A less strict, less stubborn person might not be so quick to give up on humanity.