John Gill's Exposition of the Whole Bible
Ecclesiastes 7:15
All [things] have I seen in the days of my vanity,.... Or, "all these things" u. What goes before and follows after, the various changes men are subject unto, both good and bad; these he had made his observations upon, throughout the course of his life, which had been a vain one, as every man's is, full of evil and trouble; see Ecclesiastes 6:12; perhaps the wise man may have some respect to the times of his apostasy; and which might, among other things, be brought on by this; observing good men afflicted, and the wicked prosper, which has often been a stumbling to good men;
there is a just [man] that perisheth in his righteousness; not eternally; no truly just man ever perished, who is made so by the righteousness of Christ imputed to him; for though the righteous man is said to be scarcely saved, yet he is certainly saved: it can be true only in this sense of one that is only outwardly righteous, that trusts to his own righteousness, in which he may perish; but this is to be understood temporally and corporeally; one that is really just may perish in his name, in his substance, as well as at death, and that on account of his righteousness; he may lose his good name and character, and his substance, for righteousness's sake; yea, his life also, as Abel, Naboth, and others; this is the case "sometimes", as Aben Ezra observes, not always: or a just man, notwithstanding his righteousness, dies, and sometimes lives but a short time; which sense the antithesis seems to require;
and there is a wicked [man] that prolongeth [his life] in his wickedness; is very wicked, and yet, notwithstanding his great wickedness, lives a long time in the world; see Job 21:7.
u את כל "illa omnia", Junius Tremellius, Piscator, Tigurine version, Gejerus "omnia haec", Mercerus; "universa haec", Rambachius.