For God giveth to a man that is good in his sight wisdom, and knowledge, and joy: but to the sinner he giveth travail, to gather and to heap up, that he may give to him that is good before God. This also is vanity and vexation of spirit. Ecclesiastes 2:26 (KJV)
The word for ‘good’ is derived from ṭôb טוֹב. It means agreeable. It can also mean moral good and prosperous gain. (H2896)[1] The word for ‘sinner’ is derived from châṭâ’ חָטָא. The word-to-word translation means to ‘miss or lack.’ But a much more appropriate interpretation would be to mean ‘offender;’ i.e., somebody who offends God. (H2398)[2] The phrase, ‘to a man that is good’ can be interpreted as ‘to the person who is good before Him,’ wherein, ‘good’ is used analogous to ‘sinner.’ Qoheleth uses a similar expression in 7:26. According to Seow, “the author may be thinking analogically of the Persian court, where there were favorites of the king – those who were pleasing to the king – who received royal grants, while others were left out.” (141)
Comments: With this verse, Qoheleth seems to have reached a point of consensus amidst his diverging thoughts and confusion. To begin with, there is a clear distinction of the moral character of a good man and a sinner. And consequently, the dichotomy of wisdom and madness follows. Therefore, the illusion of ‘profit under the sun’ is now finally discarded completely as God ordain travail of the sinner. It is not life that is pointless but a ‘sinner’s life’ that is pointless. The conclusion rests on the understanding that what differentiates between wisdom and madness, a good man and a sinner is that the good man acknowledges God and not self as the center of existence and gladly embraces the limitation of creature-ness within the context of the larger creation of God. (Provan, 86)
References:
Provan, I. (2001). Ecclesiastes/Song of Songs: The New Application Commentary, Zondervan
Seow, C.L. (1997). Ecclesiastes, Yale University Press
[1] https://www.blueletterbible.org/lexicon/h2896/kjv/wlc/0-1/
[2] https://www.blueletterbible.org/lexicon/h2398/kjv/wlc/0-1/