Ecclesiastes 2:21

Amplified Bible (AMP)
For there is a man who has labored with wisdom and knowledge and skill, yet gives his legacy to one who has not labored for it. This too is vanity and a great evil.

Read Ecclesiastes 2:21 in other translations