When you find yourself getting angry, a joke can lighten the mood and put your feelings back into perspective. In fact, laughter can be thought of as an incompatible mood state with anger in that the psychological state of finding something funny is inconsistent with the psychological state of anger. For even a brief moment, when someone finds something funny and laughs, their anger has dissipated (it is a lot like how you cannot be anxious and relaxed at the same time so relaxation can be used to treat anxiety).
There is more than that with humor, though. Almost by definition, humor represents a different way of looking at things. Often, something is funny because we are looking at that thing in a new light. It’s called cognitive shifting and it is when we perceive something to be fundamental different than we originally considered it. When you apply this to an angering situation, a frustrating thing becomes a silly thing, and a provocation might become less angering.
An important caveat, though, is that humor works best when it is directed at a situation instead of at a person. Humor directed at a person, via sarcasm or some other mechanism, can be an act of aggression that ends up exacerbating problems. Instead, try to direct it at the outrageousness of a situation or maybe even at yourself.