The passage from Ecclesiastes is itself a translation of course, and though it is a very old translation it's not particularly good.
'I returned and saw under the sun' - where exactly is the speaker supposed to have returned from?
What is being conveyed, poorly, is that the speaker is having a moment of clarity.