Ecclesiastes 2:21
For there is a man whose labour is in wisdom, and in knowledge, and in equity; yet to a man that hath not laboured therein shall he leave it for his portion. This also is vanity and a great evil.
Cross-reference
Ecclesiastes 2:17 expresses the hatred of life that arises from the very injustice described in 2:21—toil wasted on another.
Ecclesiastes 2:18 states the same frustration—hating toil left to another—and provides the basis for the specific case in 2:21.
Ecclesiastes 1:2 declares all is vanity — this verse exemplifies that claim, calling the specific situation 'vanity and a great evil'.
Ecclesiastes 4:4 also addresses the vanity of toil, attributing it to envy — a different cause but the same conclusion about labor's futility.
Psalm 39:6 echoes this exact frustration: man heaps up wealth but doesn't know who will gather it — a clear parallel to laboring for another's benefit.
Psalm 49:10 reinforces the same thought: even the wise die and leave their wealth to others — directly paralleling the futility of laboring for another.