I asked a Muslim friend, why did Allah create humans? 

He presented the following tradition, where Allah said (link):

کنت کنزا مخفیا فاردت ان اعرف فخلقت الخلق لاعرف

Translation:
I was a hidden treasure; I wished to be known. Hence I created the creatures so that I could be known.

Upon that, I further asked my friend: "Why did Allah “wish” to be known? And that too, from a creature which Allah created himself?"

Moreover, when Allah started “wishing” something, then He is no more al-Samad (ٱلصَّمَدُ). 

Quran 11:2:

‏ٱللَّهُ ٱلصَّمَدُ ‎

Translation:
"Allah, the Eternally-Self-Sufficient/Independent-of-All (Himself in no need of anything)

Therefore, such a thing could never be an Eternal/Independent God, which starts “wishing” for something.

My friend didn’t answer it, but he further quoted the following verse

Quran 51:56:

‏وَمَا خَلَقْتُ ٱلْجِنَّ وَٱلْإِنسَ إِلَّا لِيَعْبُدُونِ

Translation:
I have not created the jinns and mankind except to worship Me.

I said to my friend: “When someone starts “wishing” (or starts needing) to be “worshipped”, then that thing is no more al-Samad (ٱلصَّمَدُ), and thus could not be a God. 

And again, it makes absolutely no sense that Allah “wishes” to be worshipped by creatures, which He created himself. 

If Allah really created them for only “worship”, then there are 2 options for it:

  • First, this worship benefits Allah. But in this case, Allah is no more al-Samad (ٱلصَّمَدُ). This makes the writer of the Quran to be a liar. 
  • Second, this worship does not benefit Him, but He is like a person who loves to be praised all the time by his subordinates and feels happiness in it. And this is known as Psychological Disease/Disorder. 

Note: 

These are not only jinns and mankind, but angels too have been worshipping the so-called Allah since the time of their creation. What is the purpose of their “worship”?

Moreover, the writer of the Quran told one more reason for the creation of humans and Jinns.

Quran 7:179:

وَلَقَدْ ذَرَأْنَا لِجَهَنَّمَ كَثِيرًا مِّنَ ٱلْجِنِّ وَٱلْإِنسِ ۖ

And surely, We have created many of the jinns and mankind for Hell.

This Allah is strange, who now also wishes to create mankind and jinns in order to fulfil hell. 

So, Allah made the following 3 claims for creation:

  1. While he wished to be recognized by the creatures that he himself created.
  2. While he wished to be worshipped.
  3. While he wanted to fill the hell. 

All these 3 claims are making absolutely no sense. 

In simple words, Allah failed miserably in telling any suitable reason for the creation of the universe and mankind. 

If Allah was Eternal, why did He create the universe only 13.8 years ago? 

If Allah was Eternal, why did He wish to be worshipped only 13.8 billion years ago? 

Can we assume that Allah became extremely bored some 13.8 billion years ago, and thus he created a game, which had 2 characters of Mankind and Satan, and now Allah enjoys their Dramas in order to get rid of His boredom? 

Why is Allah worried in this vast universe, about our earth, and then about mankind, which came here (on the earth) only 6000 years ago (according to Islam), and then our small house, and then about our bedrooms to see if we are worshipping Him or not? 

Alone in our galaxy “Milky Way”, there are billions of stars present like our earth. And there are billions of galaxies present in the universe. What is then the purpose of the creation of this vast Universe? 

According to the Authentic  Ahadith (Traditions), the time of arrival of Mahdi is soon to be expected, as Muslims have been dominated by the non-Muslims. And once Mahdi comes, then he is not going to explore space and the universe with spaceships, but there is going to be Doomsday, and all the heavens are going to fall on the earth and the whole universe is going to be destroyed.

Thus, again the question is, what is then the purpose of the creation of such a vast universe?

Muslim Response:

There is absolutely no response from Muslims on this topic. Whenever they are asked this question, they come up with verse 56:51 where Allah claims that He created jinns and mankind for His worship.

But this verse does not give the "reason/logic" behind the creation, it is merely a statement which describes the task of jinns and mankind After Their Creation.