“Grief is better than merriment, for with an evil face the heart does well.”
Solomon continues the idea of contrasting the benefits of the house of mourning versus the house of merrymaking, yet here is focus is a little more personal. You see, here he seems to be focusing on the countenance of the individual and he observes that when you are celebrating and merrymaking, you do not tend to think deeply about life or about what you are doing. Indeed, often such places are devoid of any meaningful thought. Yet, when one grieves, one thinks more deeply and often ponders one’s words and actions carefully.
This should not be understood to read that one should always pursue mourning in life — one needs joyful laughter as well. But here, as in the previous verses, is a contrast of extremes being laid out. And, if one is to go to an extreme, this is better than that. Deep contemplation (even if as a result of sadness, exasperation, or weariness) is better than mindless folly. That is a very different perspective than most westerners seem to have today.
The Babylonian Talmud (Shabbat 30b) takes a somewhat different approach to this text and argues that the anger of God toward the righteous (God’s discipline) is better to receive than the mocking of God in derision. There is a great deal of truth to this principle (discipline is for our building up and God mocks his enemies who will one day be destroyed), but it seems a little forced to draw out from this particular verse and is not consistent with the larger context around the verse. So while this offers an important application of Biblical principles, I think we need to be careful in applying that principle here.