(And We created not the heaven and the earth and all that is between them without purpose! That is the consideration of those who disbelieve! Then woe to those who disbelieve from the Fire!) (38:27)
مَا خَلَقْنَاهُمَا إِلَّا بِالْحَقِّ وَلَـٰكِنَّ أَكْثَرَهُمْ لَا يَعْلَمُونَ "We did not create them but with true purpose, yet most of them do not know. (44:39) " In other words, every wise and thinking person should realise that there is a purpose and objective for creating this universe. The heavens and the earth and everything created in them manifest many realities. Examples are: (1) the manifestation of Divine power; (2) the possibility of the Hereafter. Obviously, the Supreme Creator Who drew out such huge bodies from the realm of non-existence into the realm of existence surely has the power to destroy them and re-create them; (3) the need for retribution (reward/punishment). If there is no retribution in the Hereafter, the very existence of the universe would be rendered purposeless or its purpose would be defeated. The wisdom underlying the creation of the universe is to make it dar-ul-imtihan (the domain of test-n-trial) and the Hereafter is the domain of reward and punishment. Otherwise, the outcome of both good and bad will necessarily be the same. This is far from Divine wisdom, or not in keeping with Divine wisdom; and (4) urging the thinking people to obey Allah and thank Him for having granted man this entire universe or creation as His great blessing
Tazkirul Quran
Maulana Wahiduddin KhanOn ayahs 42–49
If one ponders over the system of heaven and earth—indeed, of the entire universe, it will become clear that its creation was effected with a definite purpose. Had this not been so, it would have been impossible in this world for man to build up glorious cultures. Its entire functioning being meaningful is an indication that it will end also in a meaningful and purposeful way. It is unimaginable that its end could be otherwise. Its end, in reality, will herald the commencement of the life Hereafter. And belief in the Hereafter is but an extension of universal meaningfulness. The present stage of the world is that of trial. So, everyone finds his share in the meaningfulness of this world. But, in the Hereafter, only those who are actually deserving in the eyes of God, will find a share in the meaningfulness of the afterlife.
Uthmani text of the Madinah mushaf (King Fahd Complex). Translation: Saheeh International. Tafsir via Quran.com.