I think the misleading word is joke. It isn't necessarily something that is funny in the way that riddles and funny stories are. More like a practical joke played by the universe on someone. Like many practical jokes it is often not funny for those it is played on but often carries an element of "poetic justice" (see below). By definition the event has to be coincidental not the deliberate act of another person.
Does that make sense to others?

Poetic justice is when the punishment is particularely well fitted to the misdeed or the misdoer. e.g. the arsonist who dies in an accidental fire.