In my point of view humor has an important role in life, but depends a lot on with who you are talking, is not the same to one friend that to a person that you don't know.
On the other hand, I think it is not necessary to use humor when a person is sad, because it's probably that his/her reaction will be had.
Finally, the best way that you can learn of life, is that life is only a joke and you have bring with us sometimes the jokes have a good endings and you have to think the same with your life.
I'm a professional joker and at the moment my life is a joke.