The wisdom behind the creation of man
Question

I am a non-Muslim, but I would like to know what Islam says about why man was created. Is there a specific reason? What is the purpose of existence? Is it only to obey God?
Praise be to Allah.We believe that Allah (God) is the Creator of humankind, and that it is He alone Who created all that exists, animals, birds, insects, fish and so on, including humans and jinn. And we believe that He did not create them in vain, as He says in the Qur’an (interpretation of the meaning):
{We have not created the heavens and the earth, and all that is between them, in vain}
[al-Anbiya’ 21:16].
And we believe that He has favoured man over all other creatures by giving him reason, hearing, sight and understanding, and given him the power of speech, as He says in His Book:
{We have indeed honoured the sons of Adam, given them means of transportation on land and sea, provided them with good things, and have favoured them above many of those whom We have created}
[al-Isra’ 17:70].
Allah has made man distinct from other creatures, so when He gave him reason and understanding, He enjoined him to worship Him, for man knows who created him, so Allah commanded him to worship Him, for He is his Lord and Master, and the master has rights over His slaves. Thus Allah created humanity to worship Him, hence He says:
{And I did not create the jinn and mankind except to worship Me}
[adh-Dhariyat 51:56].
Allah states that humans were not created as animals were created, as He says:
{Did you think that We created you without purpose, and that you would not be brought back to Us?}
[al-Mu’minun 23:115].
Thinking that we were created without purpose is wrong thinking.
And Allah says:
{Does man think that he will be left unchecked?}
[al-Qiyamah 75:36],
that is, that he will be neglected and left with no commands and no prohibitions, and will not be made accountable.
As Allah has made humanity distinct from other creatures, in His wisdom He commanded man to worship Him, forbade unlawful things to him, and promised him Paradise in return for obedience. He told him that He will bring him back to life after death, and he will receive his requital in full. Whoever believes that is one of the righteous believers, and whoever disbelieves that has disobeyed Allah, may He be exalted, and is exposed to punishment in this world and in the hereafter, and he harms no one but himself.
And Allah knows best.