I think Ecclesiastes is a marvelous book and properly included as teaching truth. I love the way Solomon bares his soul.
I found this as part of a summary on the book:
"He looked like he had a wonderfully fulfilling life, but when he looked back at it, he realized that the deeds, pleasure and accomplishments did not mean anything without a close relationship with the Creator. An outward form of religion never provides a substitute to a close relationship with the Almighty God. The world stood up and recognized Solomon's great achievement, but he unashamedly admits that having all and not having God is absolute meaningless.
Down deep in Solomon's heart, there was a seed of corruptness that was not kept under self-control. It grew out of control and distorted his life perspective. Only later in life, did he finally observe the difference between life and living. Life could not find its meaning in the many projects that he had involved himself in. They only became distractions to the real meaning in life, only found in God. God was near his heart but not his first love. He loved other things more than the Lord. His life before this writing clearly showed this."
I think its a good example of self reflection and gives us an even better insight into the man, the king who built the temple.
The teaching that "all is vanity" or "there is nothing new under the sun" are not lessons that we want to learn. But they are foundational to Jesus' teachings. Ecc 1:14KJV echoes what we all need to come to. The world is broken and only because of what God accomplishes can it be fixed. The world will pass away but the word of God will last forever.
Worldly accomplishments are no match for justification by faith. Rom 3:27KJV