Why did Immanuel Kant say that happiness isn't always a good thing?
Happiness is only good when associated with the deserving of being happy. In this basis, only the one who conforms himself to morality deserves being happy. For example, who is honest all life deserves being happy, but a corrupt, a robber, a rapist, etc., doesn't deserve it. So, for a real Summum Bonnun, happiness can only be a conditioned good (conditioned to the amount of worthy of being happy), and not a good in itself, as an end of the Creation. And you are only worthy of being happy when you conform to morality.
If you didn’t conform to morality, you have to reestablish the worthy of being happy, which can be only done by being punished (by the law, not privately) for all violations (which means to submit to unhappiness for some time). So, a robber can reestablish the worthy for being happy after being in jail for some time, proportionally to his crimes, etc… And the amount of punishment (unhappiness) is established by ius talionis.
For me, Immanuel Kant says that happiness isn't always a good thing simply because Humans can project Happiness outwardly or externally by showing a big smile on their face, but deep within them they actually denied the pain or emotional struggles they are facing in. People just only compensating when they say that they are happy, but the truth is that they just denying it. In addition, many people could say that they're happy, but only on the word they are about to spoke and not on their actions being shown. To elaborate it more, we can say that we are happy but actually don't, coz sooner or later it will manifest outwardly and someone will surely discerned/distinguished it. In application or practically speaking: A human could not be happy when there someone in his family suffering from serious health condition, or lets just take it into more serious talk: A human could not be happy when there is loss within his family (i'm pertaining about the death of loveones).