Yet he struggled to pass the time. Having the equivalent of billions of [insert favorite currency here], most folks fantasize about the ideal life. We often believe all of our immediate problems go away, free to do whatever we want. Yet, at least in Solomon's case, he seemed to become incredibly fed up with these grand projects and plans of his own devise.
While I certainly wouldn't mind a fraction of that wealth myself, I do recall my college weekends. Free to spend time however I pleased, with my basic needs met and no homework looming, I spent hours playing my favorite video games. And yet, no matter how good they were, I remember how dull and boring they eventually became in only a few hours.
Imagine you'd spend your life creating useful inventions, somehow improving this world, helping others, clean up pollution, etc. Making the lives of people currently alive and all their descendants just a little bit more fun, happy, comfortable or interesting.
Now imagine you'd spend your life doing shitty stuff that spoils the fun and makes life miserable for everyone & those that live after you.
Note that "all their descendants" could be many many billions or even trillions+ humans (if humanity manages to not go extinct 'soon'). That's ignoring other living creatures.
With that in mind, wouldn't it be a small sacrifice to put in a bit of effort to not screw things up for those that come after you?
No need to be a saint. It's about finding a balance between having some fun for yourself, while not spoiling the fun for others - presently alive or in the future.
Religion need not enter this consideration. If it helps/comforts anyone to use as guideline, power to them. But a simple "how would future humans look back on my actions?" does the job.