(and what the Bible says to contradict what many people – especially prosperity gospelers – mean when they say this)
. . . when you only say it in good times, but blame God when trouble comes.
Naked I came from my mother’s womb, and naked shall I return. The LORD gave, and the LORD has taken away; blessed be the name of the LORD (Job 1:21).
But I with the voice of thanksgiving will sacrifice to you; what I have vowed I will pay. Salvation belongs to the LORD! (Jonah 2:9, when Jonah was in the belly of the fish).
give thanks in all circumstances; for this is the will of God in Christ Jesus for you (1 Thess 5:18).
. . . when you say it to those who are suffering.
And we know that for those who love God all things work together for good, for those who are called according to his purpose (Rom 8:28).
Count it all joy, my brothers, when you meet trials of various kinds, for you know that the testing of your faith produces steadfastness. And let steadfastness have its full effect, that you may be perfect and complete, lacking in nothing (Jas 1:2-4).
Blessed are you when others revile you and persecute you and utter all kinds of evil against you falsely on my account. Rejoice and be glad, for your reward is great in heaven, for so they persecuted the prophets who were before you (Matt 5:11-12).
. . . when you say to those who are suffering that their faith is weak.
Blessed be the God and Father of our Lord Jesus Christ, the Father of mercies and God of all comfort, who comforts us in all our affliction, so that we may be able to comfort those who are in any affliction, with the comfort with which we ourselves are comforted by God. For as we share abundantly in Christ’s sufferings, so through Christ we share abundantly in comfort too. If we are afflicted, it is for your comfort and salvation; and if we are comforted, it is for your comfort, which you experience when you patiently endure the same sufferings that we suffer. Our hope for you is unshaken, for we know that as you share in our sufferings, you will also share in our comfort. (2 Cor 1:3-7)
In this you rejoice, though now for a little while, if necessary, you have been grieved by various trials, so that the tested genuineness of your faith—more precious than gold that perishes though it is tested by fire—may be found to result in praise and glory and honor at the revelation of Jesus Christ (1 Pet 1:6-7).
But make no mistake about this: God is good all the time, infinitely good. He can’t be otherwise. It is his intrinsic character to be good. The Westminster Confession of Faith 2:1 summarizes God’s infinite goodness:
There is but one only, living, and true God, who is infinite in being and perfection, a most pure spirit, invisible, without body, parts, or passions; immutable, immense, eternal, incomprehensible, almighty, most wise, most holy, most free, most absolute; working all things according to the counsel of his own immutable and most righteous will, for his own glory; most loving, gracious, merciful, long-suffering, abundant in goodness and truth, forgiving iniquity, transgression, and sin; the rewarder of them that diligently seek him . . .