“this is the gift of God.” Many verses in Ecclesiastes encourage people to rejoice and have fun in life (cp. Ecc. 2:24-25; 3:4, 12-13, 22; 5:18-19; 8:15; 9:7-9; 10:19; 11:7-8). See commentary on Ecclesiastes 2:24.
That being able to enjoy life is the gift of God is also in Ecclesiastes 5:13. It is a gift of God to be able to have the health, financial ability, and freedom to enjoy life. God desires that for all people, but historically few have really had what it takes to enjoy life. Many people fight physical disabilities, or they are under harsh taskmasters that make life a continuous toil. One of the exciting promises about the next life is that it will be one of great joy (Isa. 35:10; 51:3; 61:7; Jer. 31:13). Life in the coming kingdom of Christ on earth will be truly wonderful. [For more on the coming kingdom of Christ on earth, see Appendix 3, “Christ’s Future Kingdom on Earth”].