Foreshadowing is a tool that writers use to give readers clues about what to expect later on in the story and also to ratchet up the suspense. Skilled use of foreshadowing can also give a story a feeling of conclusion: all the hints connect together to complete our understanding of what has happened. (This is exactly what happens in the movie The Sixth Sense, for example.)
Herbert's death is foreshadowed several times by Herbert himself. After his father makes his first wish, Herbert says, "Well, I don't see the money, [...] and I bet I never shall" (1). That's right, Herb, you're never going to see the money – because you're going to die first.
Before his parents go to bed, Herbert seems to foreshadow his own disfigurement and return from the dead:
"I expect you'll find the cash tied up in a big bag in the middle of your bed [...] and something horrible squatting up on top of the wardrobe watching you as you pocket your ill-gotten gains." (1.65)
If Mr. White hadn't used his third wish (presumably) to send Herbert back to the grave, this might have been exactly the scenario that played out. Mangled from his accident and rotting from his time in the graveyard, Herbert would have been that "something horrible" if Mrs. White had managed to let him into the house.