A joke is a story. Our friend Nicholas explains that well enough.
It’s also worth noting that many stories can be made better through humor, even darkly dramatic ones. Shakespeare made great use of comic relief in his plays (like the grave-digger scene from Hamlet below). Modern films often use plucky sidekicks to break up tension.
One of the masters of this is the filmmaker Sam Raimi (creator of the Evil Dead series) who often mixes comedy in his horror films as a change of pace.
The point is that no matter how darkly dramatic your story is, you need to change the temperature and texture of it every so often or your audience will start to grow numb. Humor is a fantastic way to break your stories up, give them context and keep your audience guessing.