I once heard a representative of the Jewish community being interviewed on the radio on the topic of Purim.
Laughter occurs when the unexpected happens.
When two contrary elements are juxtaposed, the sudden surprise catches us off guard. And the more unexpected it is, the funnier it is. In the days of Mordechai and Esther, the Jews went from being the target of annihilation, to being the heroes and victors. It was a miraculous 180-degree shift in fortune. Joy comes both from seeing justice served upon our enemies, as well as being raised from the pit ourselves.