Briefly, The Mayor of Casterbridge is the tale of a man who sells his wife when drunk, has a chance to make amends, and lives the rest of his life trying to keep various truths secret from his family and his community. Like most Hardy, marriage (both the pursuit and the experience thereof) fosters lies, pain, andunhappiness. Heroines fall in love only to be thwarted, while gentlemen perform various indiscretions and are unhappily surprised, later, to realise that actions have consequences.
The plot of this novel is a bit complicated, abundantly described elsewhere on the internet, and filled with spoilers for readers who want to experience the book for themselves, so I'll skip over that. Instead, I want to think about marriage as I've seen it in Hardy novels, where it has almost always been plagued by secrets and unhappiness.
Harding, in the mind of an old man named Mr. Henchard, describes him looking in on a wedding-feast with terrific cynicism:
"The gaiety jarred upon Henchard's spirits; and he could not quite understand why Farfrae, a much-sobered man and a widower, who had had his trials, should have cared for it all, notwithstanding the fact that he was quite a young man still, and quickly kindled to enthusiasm by dance and song. That the quiet Elizabeth, who had long ago appraised life at a moderate value, and who knew, in spite of her maidenhood, that marriage was as a rule no dancing matter, should have had zest for his revelry surprised him still more" (325).Of the three named characters here, Henchard is the eldest, and has been married (twice) to a woman whose presence he found very restrictive. He has also had a level of intimacy (specifics undisclosed) with another woman, of whom he was purportedly rather fond (he spends many pages pining after her). Farfrae, the widower, is sober but also the only character in the book to have had anything even remotely resembling a happy marriage. Elizabeth has had some disappointments but has managed to save her "maidenhood" for someone she appears to genuinely enjoy (and her beau/husband buys her lots of books, which is his most lovable quality in my opinion!).
Taking their relative character traits and life experiences into account, it isn't really that surprising that the wedded couple are dancing happily. More to the point, though, this cynicism--believable as Henchard's disillusionment makes it--seems less Henchard's and much more Hardy's. In Hardy, even the happiest of marriages (or consummated pledged unions that reject the confines of religious ceremony) must be tainted by a threat of darkness, and this wedding fits the bill. Throughout the novel, pure happiness is almost exclusively described from the perspective of outsiders, and particularly by bitter, unhappy, or disillusioned outsiders. Henchard's past experiences, which lead to bitterness, remove any sense of happiness from a moment that most readers would otherwise associate with fulfillment and contentment. This is dark and clever writing.
One other intriguing feature not just of The Mayor of Casterbridge but also of Hardy more generally is that the plots of his stories, thus far, intend to show the failures of marriage but usually end up revealing the consequences of premarital sex or later infidelity. I don't think Hardy means to do this, but in The Mayor of Casterbridge, all the characters who break their marriage vows (in this instance through sale rather than sex) later suffer because of of their actions and, usually, because they concealed those actions. Although nobody in this novel blackmails anyone else, many of the characters expect to be blackmailed. Suffering comes both when concealed activites are brought to light, but also when concealed activities are known by any other character, even those who bear no malice towards the character in question.
Overall, I quite liked this novel. Hardy's darker style of writing is appealing to me, as is his repeated use of moments when the reader and a character share a glimpse of dramatic irony together. His characters frequently confess indiscretions of the past to one another, always without names, which leads to a series of misunderstandings in which the reader knows exactly how the complications have arisen while the characters are secretive, oblivious, or both. On the other hand, there is not a great deal of repentance or redemption; characters who sin seem to see life and fortune as great conspirators against them, rather than accepting responsibility for their own actions and decisions. While dark and intriguing, Hardy's book is an unrelentant study in mankind's constant proclivity to sin and blame others.