He Almighty commanded them to thank Him. (“Work gratefully, O family of David!” ) And it is a command for them to show their gratitude for the blessings on His creation.
أمرهم الله تعالى بشكره. (اعْمَلُوا آلَ دَاوُودَ شُكْرًا ۚ) وهو أمرٌ لهم بشكر الله على أنعامه على عباده.