Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:21:16

And We did not create the heaven and earth and that between them in play.  

And We did not create the heaven and the earth and all that is between them, playing, being frivolous, but to indicate Our power and to benefit Our servants.
القرآن:٢١:١٦

وَمَا خَلَقْنَا السَّمَاءَ وَالْأَرْضَ وَمَا بَيْنَهُمَا لَاعِبِينَ  

{وما خلقنا السماء والأرض وما بينهما لاعبين} عابثين بل دالين على قدرتنا ونافعين عبادنا.

See similar narrations below:

Collected by Qurʾān
quran:44:38

And We did not create the heavens and earth and that between them in play.  

And We did not create the heavens and the earth and all that is between them, ˹intending˺ to play, by creating all that (lā‘ibīna, ‘to play’, is a circumstantial qualifier).
القرآن:٤٤:٣٨

وَمَا خَلَقْنَا السَّمَاوَاتِ وَالْأَرْضَ وَمَا بَيْنَهُمَا لَاعِبِينَ  

{وما خلقنا السماوات والأرض وما بينهما لاعبين} بخلق ذلك، حال.