I said in my heart, “God will judge the righteous and the wicked, since there is a time for every activity and every deed.”
Solomon is still showing that every thing in this world, without piety and the fear of God, is vanity. Take away religion, and there is nothing valuable among men, nothing for the sake of which a wise man would think it worth while to live in this world.
Commenting on Ecclesiastes 3:16-22
I said in mine heart, God shall judge the righteous and the wicked,.... This he considered in his mind, and set it down for a certain truth, and which relieved him under the consideration of the sad perversion of justice; and made him easy under it, and willing to leave things to him that judgeth righteously, and wait his time when everything that was now...
Solution of it. There is a coming judgment in which God will vindicate His righteous ways. The sinner's "time" of his unrighteous "work" is short. God also has His "time" and "work" of judgment; and, meanwhile, is overruling, for good at last, what seems now dark. Man cannot now "find out" the plan of God's ways (Ecc 3:11; Psa 97:2).