Ecclesiastes is a difficult book. The reason is probably because Solomon was seeking pleasure and wisdom from a humanistic perspective. But by the time he gets to the end of the book, Solomon has clearly shown that from a humanistic perspective, life has no meaning or purpose. It is all vain. Solomon concludes in this way, “Fear God and keep His commandments, for this is man’s all. For God will bring every work into judgment, including every secret thing, whether good or evil” (Eccles 12:13-14).
Solomon understood very advanced truth, what Paul and the author of Hebrews call “solid food” which “belongs to those who are of full age [= mature]” (1 Cor 3:2; Heb 5:12, 14). To see how significant his closing words are, let’s compare them with the teachings of the Lord and of Paul.
The NT refers to the judgment of church age believers as the Judgment Seat of Christ (Rom 14:10-12; 2 Cor 5:9-10). Solomon recognizes that believers of all ages will be judged according to their works: “God will bring every work into Judgment.” We do not know what the judgment of OT saints will be called. Of course, it is possible that the Judgment Seat of Christ (Bema) would include the judgment of both church age saints and OT saints. But more likely there will be a separate judgment for OT believers.
Solomon also knew that God will even judge “every secret thing.” That same idea is found in the teachings of the Lord Jesus: “For nothing is secret that will not be revealed, nor anything hidden that will not be known and come to light” (Luke 8:17, which is parallel to Matt 10:26; Mark 4:22; and Luke 12:2). It is found in Paul as well: “Therefore judge nothing before the time, until the Lord comes, who will both bring to light the hidden things of darkness and reveal the counsels of the hearts…” (1 Cor 4:5). See also Matt 6:4, 6, 18; Rom 2:16.
The very last words of Ecclesiastes reflect advanced truth as well. Every secret thing which will be brought into judgment does not refer merely to all good deeds done in secret (cf. Matt 6:4, 6, 18). Instead, it refers to all secret things, “whether good or evil.”
The words whether good or evil are repeated by Paul: “For we must all appear before the judgment seat of Christ, that each one may receive the things done in the body, according to what he has done, whether good or bad.” The words are almost identical in the two references. The Greek version of Solomon’s closing words are agathon kai ponēron. The Greek of Paul’s last words in 2 Cor 5:10 are agathon…kakon. (A small number of early Greek manuscripts read phaulon instead of kakon. However, every time in the NT where agathon is contrasted with phaulon, it always means whether good or evil. See pp. 31-32 here.)
Of course, many believers think that any bad deeds we have done, especially secret bad deeds, will not be judged at the Bema. Or they think that if their bad deeds have been confessed, they won’t be judged. While it is true that our sins will not be judged at the Bema as sins, our sinful deeds are bad deeds and they will be judged to determine our eternal rewards. I have written a twenty-page paper on this question: “Will the Bad Deeds of Believers Be Considered at the Bema?” See here (pp. 17-36) or here if you want to see the details. (See also this article by me dealing with the ending of 1 Cor 4:5, “Then each one’s praise will come from God.”)
How did Solomon know these things? By special revelation from God. Not by logic, reason, or intuition. God revealed these things to him.
While Solomon tragically did not persevere in the faith but died as an idolater (1 Kings 11), he was one of Israel’s greatest kings, an author of three books of Scripture, and one of the wisest men who ever lived. His closing words in Ecclesiastes are well worth taking to heart.