John Gill's Exposition of the Whole Bible
Ecclesiastes 6:12
For who knoweth what [is] good for man in [this] life?.... To be in a higher or lower station of life, to live in grandeur or meanness, to be rich or poor, learned or unlearned; since that which seems most agreeable to human nature is at, ended with so much vanity, the occasion of so much sin, and often issues in ruin and misery, that no man knows what is best for him; and therefore it is the wisest way to be content with what a man has, and enjoy it in the most comfortable manner, and use it to the best ends and purposes he can. The Targum is,
"for who is he that knows what is good for a man in this world, but to study in the law, which is the life of the world?''
so the Midrash,
all the days of his vain life, which he spendeth as a shadow? or "the number of the days of vain life, which he makes as a shadow" d; that is, which God makes as a "shadow", as Cocceius observes; makes to pass away swiftly: this is a description of the vanity, brevity, and uncertainty of human life; it consists of days, rather than of months and years; and those such as are easily numbered, and which pass away suddenly and swiftly, like a shadow that has no substance and reality in it, and leaves nothing behind it; or like a bird that flies away, as Jarchi, and is seen no more; such is the life of man, a most vain life, vanity itself; so it may be rendered, "the number of the days of the life of his vanity" e; since therefore he has so short a time to enjoy anything in, it is hard to say what is best for him to have, and the rather since he is quite ignorant of what is to come;
for who can tell a man what shall be after him under the sun? he does not know himself, nor can any man inform him, what will become of his wealth and riches after his death, which he has got together; who shall enjoy them, and how long and what use will be made of them, either to their own good, or the good of others.
d ויעשם כצל "et facit eos at umbram", Cocceius. e מספר ימי חיי הבלו "numero dierum vitae", ("vitarum", Montanus), "vanitatis suae", Pagninus, Rambachius.