v. 12-16 "Then I turned my thoughts to consider wisdom, and also madness and folly. What more can the king's successor do than what has already been done? I saw that wisdom is better than folly, just as light is better than darkness. The wise man has eyes in his head, while the fool walks in the darkness; but I came to realize that the same fate overtakes them both. Then I thought in my heart, 'The fate of the fool will overtake me also. What then do I gain by being wise?' I said in my heart, 'This too is meaningless.' For the wise man, like the fool, will not be long remembered; in days to come both will be forgotten. Like the fool, the wise man too must die!"
This seems like he is saying give up on being wise since we will just die anyway, but I do not think that this is as hopeless as it sounds. We all are given a choice in this life, to pick good or evil. This is a choice only we can make and it will determine our eternal place. Wisdom alone can not guarantee eternal life, but it is better than folly. God is looking for quality in us, not quantity. We all are to die at some point no matter how we live our lives. What we do here will have an impact on our eternal reward. If we focus on a relationship with God and not struggle for earthly gain then we will be much better off here and there.
Most everything on earth at some point will disappoint us, but not God. We may not be happy with His timing or what He is allowing in our lives, but we do not know what His plans are for us, so we do not have all the details to make a correct conclusion. When we are at judgment there will be no one with us, we will be judged on what we did while here on earth. Every little thought, our actions, how we treated family, friends and strangers, how we spent our time and money will be on trial before God. I already have many things in my past that will be on trial before God, I can not change that, I can only try and live the rest of my life so that when I am judged He will be pleased with me that I accepted His invitation to know Him and turn away from my former sins and live for Him.