The comparison خَيْرٌ مِنَ الدُّنْيَا وَمَا فِيهَا sets sincere effort in Allah’s cause against the world's possessions. The comparative word خَيْرٌ highlights value beyond financial price or outward length of time.
For example, someone who fulfills ordinary responsibilities and also gives sincere time to learning, teaching, or serving others acts for a purpose that cannot be assessed only by money or fame.
The general lesson is to use limited opportunities with care, remembering that immediate gains are not the only measure of a deed's worth.