In the book of Ecclesiastes, the "Teacher" declares over and over again that everything is meaningless. Life, toil, wisdom, foolishness, tears, and laughter are all meaningless. I always found the entire book rather confusing, but the last two verses at least are clear enough:
Ecclesiastes 12:13-14 (NIV)
13 Now all has been heard;
here is the conclusion of the matter:
Fear God and keep his commandments,
for this is the whole duty of man.
14 For God will bring every deed into judgment,
including every hidden thing,
whether it is good or evil.
I think it serves as a sort of key to the rest of the book, but I was still confused until today when I had a bit of an "ah ha!" moment, reading Ecc. 2:11:
Yet when I surveyed all that my hands had done
and what I had toiled to achieve,
everything was meaningless, a chasing after the wind;
nothing was gained under the sun.
The things we do under the sun are not meant to be rewarded in life, but the efforts we make to please God and live righteously are taken into account at judgment. We reap what we sow, but in a different field: we're storing up treasures in heaven by serving God.
What he does take with him is the sum of his deeds, which he will be judged for accordingly, along with the attitude with which he lived. Another theme that is repeated throughout Ecclesiastes is taking pleasure in your work:
Ecclesiastes 5:15 (NIV)
15 Naked a man comes from his mother's womb,
and as he comes, so he departs.
He takes nothing from his labor
that he can carry in his hand.
24 A man can do nothing better than to eat and drink and find satisfaction in his work. This too, I see, is from the hand of God, 25 for without him, who can eat or find enjoyment?
22 So I saw that there is nothing better for a man than to enjoy his work, because that is his lot. For who can bring him to see what will happen after him? (similarly in 3:12-13; 5:18; 8:5; 9:9)
Isaiah 14:24 (NIV)
24 The LORD Almighty has sworn,
"Surely, as I have planned, so it will be,
and as I have purposed, so it will stand.
Ecclesiastes 7:14 (New International Version)
14 When times are good, be happy;
but when times are bad, consider:
God has made the one
as well as the other.
Therefore, a man cannot discover
anything about his future.