In 2:18-26 the emphasis is on what happens to the fruits of labor that one accumulates over a lifetime of toil. These fruits include money and all it can buy, fame, and happiness.
2:18-21 Solomon viewed all his labor during his lifetime ("under the sun,"v. 18) with despair because there was no real permanence to its fruits. He would have no control over what he had accumulated or accomplished after he died (v. 19). The idea so common today that a good job is more desirable than a bad job because it yields benefits the worker can enjoy is a very short-sighted, selfish view. It seems to contradict Solomon's conclusion, but it does not. Solomon's perspective was much more altruistic. He was thinking about what long-range changes for good could come out of all his toil?
2:22-23 In view of what comes of it all, Solomon concluded that human labor costs more pain and restlessness than it is worth.
2:24-26 Since we cannot expect really significant changes to come out of our work, the best we can do is to enjoy its fruits and find some satisfaction in the work itself (cf. 3:12, 13, 22; 5:18, 19; 8:15; 9:7, 9). However this is possible only with God's help (vv. 24-25). Sometimes God channels the fruits of a wicked person's work into a righteous person's hands (v. 26).32
". . . in themselves, and rightly used, the basic things of life are sweet and good. Food, drink and work are samples of them, and Qoheleth will remind us of others [cf. 9:7-10; 11:7-10]. What spoils them is our hunger to get out of them more than they can give; a symptom of the longing which differentiates us from the beasts, but whose misdirection is the underlying theme of this book."33
In these verses Solomon implied that God's rewarding or punishing a person for his trust in God and his ethical behavior would take place before death. This is normally what happens (cf. Proverbs). Therefore Solomon's counsel is good advice. However from later revelation we learn that final judgment will take place after this life and that God's rewards are not just temporal but eternal (cf. Job's problem). Therefore as believers we can find greater satisfaction in our work itself than Solomon could. In short, later revelation has not invalidated Solomon's views but enriched them.