The wife's husband died. This is the suffering passive.
It's saying, (a bit too literally?)
The wife's sadness at the loss of her husband was respectfully written about in the novel.
Put in a looser translation,
The wife's grief at the loss of her husband was beautifully described in the novel.
丁寧 doesn't technically mean beautiful but I think this word in English in this context captures nicely the feeling expressed in Japanese.
Grammar-wise, consider the following
妻は夫に先に死なれた
could be rendered
The wife had her husband die on her.
which kind of captures the suffering aspect of the passive.
In the passive construct, に can mark the original subject of the sentence.
So with just this fragment, we could perhaps rephrase this (avoiding the passive) by saying
夫が妻の先に死んだ。
The husband preceded his wife in death. (a rather loose translation again)
But since it's the wife's grieving/sadness that is being described, such a non-passive structure would be difficult to work with.
Breaking this sentence down and rebuilding it bit by bit.
The core sentence is
その小説には悲しみが書かれていた
The grief was written about in the novel.
You could ask, "whose grief?" 妻の悲しみ. The wife's grief.
その小説には妻の悲しみが書かれていた
The wife's grief was written about in the novel.
You could further ask, "how was it described?" 丁寧に. Respectfully.
その小説には妻の悲しみが丁寧に書かれていた
Finally, what was the wife grieving? The fact that her husband died.
その小説には夫に先に死なれた妻の悲しみが丁寧に書かれていた