Yeah, that's a lot of tone to pack into one novel, but Hawthorne is a good writer. Check out this sentence from a very early part of the novel:
The founders of a new colony, whatever Utopia of human virtue and happiness they might originally project, have invariably recognised it among their earliest practical necessities to allot a portion of the virgin soil as a cemetery, and another portion as the site of a prison. (1.2)
Our narrator is very detached. He doesn't show any feeling toward these Puritans one way or another, although over time we get the sense that he sees some problems with their community. It's also extremely complex writing, with lots of clauses and modifiers.
Part of that complexity comes from ever-so-slight hint of wryness or skepticism that he can't help using. He notes that the founders had "originally" wanted to found a "Utopia"—a perfect place—but, nevertheless, two of the very first sites they build are a cemetery and a prison. We get the sense that the narrator is poking just a little bit of fun at the lofty, idealistic goals of the Puritan founders—and suggesting that even they didn't fully believe it.
So much for detached, complex, and skeptical; what about moralizing? Look at the way this first chapter ends:
Finding it so directly on the threshold of our narrative, which is now about to issue from that inauspicious portal, we could hardly do otherwise than pluck one of its flowers, and present it to the reader. It may serve, let us hope, to symbolise some sweet moral blossom that may be found along the track, or relieve the darkening close of a tale of human frailty and sorrow. (1.3)
Here, the narrator is directly addressing the reader, essentially telling us that every sad story has at least one little hint of brightness in it, one "moral blossom." And he's going to make sure that we pluck that moral blossom. In fact, he's going to force us to take it.