17 So I hated life , for the work which had been done under the sun was grievous to me; because everything is futility and striving after wind . 18 Thus I hated all the fruit of my labor for which I had labored under the sun , for I must leave it to the man who will come after me. 19 And who knows whether he will be a wise man or a fool ? Yet he will have control over all the fruit of my labor for which I have labored by acting wisely under the sun . This too is vanity . 20 Therefore I completely e despaired of all the fruit of my labor for which I had labored under the sun . 21 When there is a man who has labored with wisdom , knowledge and skill , then he gives his legacy to one who has not labored with them. This too is vanity and a great evil . 22 For what does a man get in all his labor and in his striving with which he labors under the sun ? 23 Because all his days his task is painful and grievous ; even at night his mind does not rest . This too is vanity .

Matthew Henry's Commentary on Ecclesiastes 2:17-23

Commentary on Ecclesiastes 2:12-17

(Read Ecclesiastes 2:12-17)

Solomon found that knowledge and prudence were preferable to ignorance and folly, though human wisdom and knowledge will not make a man happy. The most learned of men, who dies a stranger to Christ Jesus, will perish equally with the most ignorant; and what good can commendations on earth do to the body in the grave, or the soul in hell? And the spirits of just men made perfect cannot want them. So that if this were all, we might be led to hate our life, as it is all vanity and vexation of spirit.

Commentary on Ecclesiastes 2:18-26

(Read Ecclesiastes 2:18-26)

Our hearts are very loth to quit their expectations of great things from the creature; but Solomon came to this at length. The world is a vale of tears, even to those that have much of it. See what fools they are, who make themselves drudges to the world, which affords a man nothing better than subsistence for the body. And the utmost he can attain in this respect is to allow himself a sober, cheerful use thereof, according to his rank and condition. But we must enjoy good in our labour; we must use those things to make us diligent and cheerful in worldly business. And this is the gift of God. Riches are a blessing or a curse to a man, according as he has, or has not, a heart to make a good use of them. To those that are accepted of the Lord, he gives joy and satisfaction in the knowledge and love of him. But to the sinner he allots labour, sorrow, vanity, and vexation, in seeking a worldly portion, which yet afterwards comes into better hands. Let the sinner seriously consider his latter end. To seek a lasting portion in the love of Christ and the blessings it bestows, is the only way to true and satisfying enjoyment even of this present world.