The “Preacher” of Ecclesiastes has a relentless message (he doesn’t wait long to tell you, just look at the second verse of the book). The message is this: all our efforts to find happiness apart from God are useless. This life, apart from God, is meaningless, it is hopeless, and it is only filled with despair.
Now, that is an important message, because from the very beginning chapters of the book of Genesis, the Old Testament asserts this fundamental truth: that there is a Creator, He is distinct from His creation, we are His creatures, and we are not Him; and the essence of life consists in glorifying and enjoying that Creator and honoring Him as the One who is the Lord and Sovereign.
And so it is perfectly appropriate that there would be a book in the Old Testament that sets forth what happens when you attempt to live life against that truth or without that truth. If you attempt to live life under the sun, if you attempt to live life apart from the reality of a Creator that has brought all things into being and made us for Himself, then this will happen.
That’s basically the story of the book of Ecclesiastes. It is an exploration of the different ways that people try to find meaning in this life apart from God, and it is an explanation of how futile that is. It is a big argument to argue you into a corner in the denial of the Creator. So, when the author says, “All is vanity,” he really means it. Everything under the sun is vanity apart from God. Everything in this world, everything in this earthly sphere is incapable of satisfying the deepest part of our soul apart from God.
Here is a sermon series on Ecclesiastes that Derek Thomas and I preached at the First Presbyterian Church of Jackson, Mississippi back in the summer of 2003. http://www.fpcjackson.org/resource-library/sermons/by-series/ecclesiastes