Thus I considered all my activities which my hands had done and the labor which I had exerted, and behold all was vanity and striving after wind and there was no profit under the sun. (Ecclesiastes 2:11)
The key to understanding this verse, and all of the Book of Ecclesiastes, is the phrase "under the sun". Solomon, the writer of Ecclesiastes, uses this phrase 27 times in this book. "Under the sun" is Solomon's way of saying: exclusive of God, without His judgment or eternal consequences and benefits.
And it is certainly true that if there is no God, no judgment, and nothing beyond this short life and that if nothing we do has real lasting value or meaning, then indeed, all was vanity and striving after wind and there was no profit under the sun. But as Christians who have eternal life, we don't live our lives simply under the sun, i.e. excluding God and without eternal consequences or benefits. What we say, what we do, even what we think matters not only in this life, but beyond this life; For we must all appear before the judgment seat of Christ, so that each one may be recompensed for his deeds in the body, according to what he has done, whether good or bad. (2 Corinthians 5:10)
If this life on earth of 100 years or less is all there is and all that matters, then life is futile, without purpose and without hope. But Solomon understood the fact that our lives are not just lived "under the sun" and that there are lasting and eternally significant benefits, profits and hope in Christ; The conclusion, when all has been heard, is: fear God and keep His commandments, because this applies to every person. For God will bring every act to judgment, everything which is hidden, whether it is good or evil. (Ecclesiastes 12:13, 14).
Live your life, not just under the sun, but beyond the sun and to the glory of the Son, our Lord Jesus Christ! Maranatha!