I think humor is just a way many people deal with stressful or uncomfortable situations. I remember at my own grandfather’s funeral, the minister was lying about how well he knew our family and he kept mispronouncing the name of one of my aunts. Here we are at the funeral of our own dearly beloved and we are cracking up, calling my aunt by the wrong name and snickering.
Did that mean we didn’t really care for my grandfather? Absolutely not! We had been under stress for several weeks before his death, and had a rough time during the week after he died. When we finally had the funeral, we were grieving and had little sleep. Laughter just made things a tiny bit easier.
Also weirdly enough, things that weren’t especially funny in retrospect seemed hilarious at the time. I think people were looking for an excuse to laugh.
People sometimes feel guilty about thinking inappropriate thoughts. And humor is a way to voice those thoughts in a more socially appropriate manner than just outright saying rude things.