Ecclesiastes 8:14

There is a vanity which is done upon the earth; that there be just men, unto whom it happeneth according to the work of the wicked; again, there be wicked men, to whom it happeneth according to the work of the righteous: I said that this also is vanity.

The verse was written by Solomon the son of David, king in Jerusalem, after his unsatisfying experience in wealth and luxury and idolatry when his heart was led away by his many wives. It means that on earth outcomes are often reversed from what conduct deserves, with just men suffering what belongs to the work of the wicked while wicked men receive what belongs to the work of the righteous. The righteous often fare as though their deeds were evil while vice flourishes, and this seeming injustice in which events do not match character is vanity. Righteous and wicked people may thus experience outcomes opposite to what their conduct deserves.

This unfairness is seen in that useful and beautiful things are not always given to the worthy, and the wicked may enjoy more of them than the righteous. In this the verse presents the vanity of human life and the utter uselessness of all human pursuits apart from God. This unequal distribution is part of the vanity and corruption of the present world, which is now under the enemy's possession, where the rightful heirs are made to pay tribute.

Present suffering and prosperity are not, by themselves, the final reward or punishment for one's deeds. Because just outcomes are lacking in the present life, the promised inheritance of the earth for the meek cannot come through present prosperity but must be future. Amid such unequal earthly experiences, the verse points to the Father's knowledge, care, and love, and to the joy and lasting compensation found in Him. It leads to the conclusion that the whole duty of man is to fear God and keep His commandments.