“nothing better for them than to rejoice.” 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.
“to do good.” The literal reading of the Hebrew is “to do good.” But the word “good” sometimes does not have a moral implication, and has more of the implication of “enjoy,” which is why some versions have something such as “be happy and enjoy themselves” (NRSV) instead of “do good.” But it does not seem likely that God would not have some overtones of moral duty in this verse. While it is important to enjoy our lives, we must not forget that God created humankind with a purpose that was more than just having a good time. The conclusion of Ecclesiastes shows us this when it says that the conclusion of the matter is to fear God and keep His commandments, which is the whole duty of humankind (Ecc. 12:13-14). To be sure, there are verses in Ecclesiastes that focus on enjoying life, but when the text includes doing good, it is likely there because doing good is part of what God intends for people.