I think it is a way of coping with tragedy and awful events.
Some time ago I heard a guy interviewed who had investigated many, many scenes of horror such as massacres in Rwanda. They made jokes about things and he said that if anyone heard them they would be horrified ... but they needed to do it as a kind of mental protection so that they could stay somewhat detached and do their work instead of breaking down in tears at the horror of it all.
Having said that, some people are just sick and have no taste. They will just laugh and someone elses misfortune and make no attempt to help.