The novel is infinitely better. Matheson wrote a really good, quite possibly the *best*, novel about a quasi-biblical afterlife (notions of heaven, hell, atonement for sin, etc.) and movie got totally bogged down in touchy feely garbage presumably to make up for the fact that the novel is dark as fuck.
Think of the movie as Robin Williams making up for all the ways he mistreated his loved ones in life. Like his son, how he'd always put pressure on him to "apply himself" when he was already doing his best, and nothing he ever did was good enough ... well in the afterlife Robin Williams was demanding that his son face the hordes of hell, and that's when he realized how misguided he was.
(Big clue that the afterlife here is structured around Robin Williams' memories and isn't exactly an external place: the battleship. There's a flashback scene to Robin Williams' son with a model battleship, and that battleship shows up as they're about to face down the hordes of hell ... and note too that the hordes all stop when Robin recognizes his son.)
And Robin being willing to go into hell to be with his wife ... that's exactly what he DIDN'T do in life, when she was having mental problems and he was ready to divorce her. That was where he failed her, and he got a second chance to make it right. Of course they "got out" of "hell" despite all the "rules", because hell wasn't really a place of its own.