It's common to view Melville more as a proto-modern than as a writer of his time. The lack of interest his masterpiece attracted until the twentieth century, when it quickly became seen as one of the peaks of American literature, certainly suggests that Melville was specially attuned to what would be the concerns of a post-Great War, post-Darwin, post-Freud world. His antipathy toward Christian missionary work in the South Pacific, and his relative openness to the native island cultures, further marks him in our minds as one of us, not one of them, those stiff and repressed men of the nineteenth century.
But we oversimplify his art if we ignore the Christian, and largely Calvinist, worldview that still saturated the United States of his day. There's no question, of course, that Melville knew his Bible. He also appears to have had some familiarity with Bunyan's Pilgrim's Progress, which is included in the list of Melville's reading at the end of the Norton Critical Edition of Moby-Dick (2d ed.). Actually, it would be surprising if Melville were not familiar with Pilgrim's Progress, since every 19th-century Protestant who could read at all read Bunyan's allegory at least once (or it very often seems that way).
In any event, Moby-Dick maps with surprising ease to the Calvinist theology taught by Pilgrim's Progress. Moby-Dick invites the reader to consider why Ahab and all the crew except Ishmael die, while Ishmael lives. In Christian imagery, death is damnation, while life is eternal life in the Kingdom of Heaven. Further, under Calvinist theology, damnation is the ultimate fate of anyone who does not accept Jesus as Christ, the Savior and Redeemer.
The episode in Pilgrim's Progress involving the Village of Morality provides one explanation for Ahab's damnation. Pilgrim's Progress tells the story of Christian as he struggles to make his way from the City of Destruction (the state of unrepentant man) to the Celestial City (heaven). Christian must begin his pilgrimage by passing through the "wicket gate," representing the individual's acceptance of Jesus Christ. On his way to the wicket gate, however, Christian is led astray by Mr. Worldly Wiseman, who persuades Christian that the path beyond the gate is needlessly dangerous, and that he can more easily and safely put himself right with God by going to the Village of Morality. Christian then heads toward the Village. But as he approaches it, he sees that the road leading into the Village passes close under a mountain that is rumbling and spitting fire. While Christian stands in the road, looking at the mountain and wondering whether it's safe to pass, Evangelist comes upon him. Evangelist (representing the Gospel) explains to Christian that he has been duped, that the Village of Morality offers no hope, and that he must proceed through the wicket gate if he wishes to gain eternal life.
The object of all this, from Bunyan's standpoint, is that mere morality can never be sufficient for reaching heaven. God's moral law (represented by the fiery mountain) demands more than man is capable of. Those who, like Mr. Worldly Wiseman, think they can be virtuous enough to be saved without Christ do not understand the superhuman demands of God's law. Hence the importance of Jesus Christ: he offers forgiveness that enables man to reach Heaven despite man's inevitable failings.
It's possible to view Ahab coherently in these terms. He (along with the crew he misled) was damned because he put his trust in the Village of Morality. Instead of accepting God's morality and the need for Christ's mediation, Ahab relied upon his own morality. And in doing so, he carries the error of Mr. Worldly Wiseman to its logical conclusion -- Ahab takes his human conception of morality as the standard for judging not only himself but also God. He refuses to accept God unless God conforms to his mortal ideas of right and wrong.
Any interpretation of Moby-Dick that purports to explain why Ahab was damned is not complete unless it can also explain why Ishmael was saved. One Christian explanation for Ishmael's salvation is his humility. Unlike Ahab, Ishmael accepts his fallen state, his inescapable human frailty and ignorance. He does not condemn God because God fails to arrange things to suit man's limited sense of fairness.
Another explanation, more strictly Calvinist, is that Ishmael was saved for reasons we can't hope to understand; all we know is that God's grace was given to him and not the others. His salvation seems random to us because there is no cause-and-effect relationship between our conduct and God's saving grace.
Of course, while Melville was fascinated by metaphysical questions, he was not a religious author. Ishmael does not find Jesus the way he would if his story had been handled by Harriet Beecher Stowe, for example. But intentionally or not, as a thesis to be advanced or rebutted, Moby-Dick has a strong Christian thread running through it.