It’s probably worth mentioning that Solomon did abandon God for women and pagan idols at some point. And so Ecclesiastes may also carry a certain connotation of guilt and repentance. Not only that, but it could also have an Augustine’s Confessions moment, that having dedicated his life to worldly pleasures, he realized it did not make him happy and all he knew was that he deeply regretted not having followed God throughout his years in the world