Ecclesiastes 2:20

Therefore I went about to cause my heart to despair of all the labour which I took under the sun.

Ecclesiastes 2 is a firsthand account of testing worldly, carnal pleasure more thoroughly than any other man, undertaken by one uniquely situated with wealth and honor and power and wisdom, with everything his heart could wish at his command. He set himself to enjoy pleasure and kept nothing his eyes desired from them, seeking it in mirth and folly and wine. He sought it further in great works and houses and vineyards, in gardens and orchards and pools of water, in servants and maidens and great possessions, in silver and gold and peculiar treasure, and in men and women singers and all kinds of instrumental music.

It belongs to an account showing that greatness and happiness do not always go together, and reflecting on its record of worldly achievement exposes the limits of pride. Human life and its pursuits are vanity and useless apart from God, and this is part of the account of an unsatisfying experience of wealth, luxury, and idolatry whose conclusion is that fearing God and keeping His commandments is humanity's whole duty. Pursuing worldly pleasure and gain through labor leads to despair because these things are vanity and bring no lasting fulfillment. Earthly pursuits without hope in God bring vanity and vexation of spirit.

Labor under the sun leads to despair when a person sees that its gains and burdens do not last and may pass to others after death. A life consumed by worldly cares, with little thought for the life beyond, leaves a person poor in true riches, and trust in God is better than possessing this world's goods without it. The despair comes from laboring to acquire wealth without using it for good, since the labor may end in wealth being wasted or distributed to others after death. It is therefore better to do good and give while there is opportunity than to wait until one is unwilling or unable to give. Giving himself up to pleasure in this way contributed to spiritual decline and the weakening of Israel's kingdom.