Something is funny when one realizes a difference between what is expected and what actually happens.
The Danish philosopher Kierkegaard said:
"Man is the only animal that laughs and weeps: for he is the only animal that is struck with the difference between what things are, and what they ought to be"
"Man is the only animal that laughs and weeps: for he is the only animal that is struck with the difference between what things are, and what they ought to be"
"Peter McGraw theorized that humor is found when a violation or a disruption of one& #39;s expectations or sense of normality occurs. This is only true when this disruption is benign and unharmful to others."
This might explain why when things go wrong to the point that it might be "dark" or even somewhat painful, we find it funny and joyful.