Why God Created Mankind
Question

According to the Quran and/or Islamic traditions, why did God create mankind?
Praise be to Allah.Allah created the jinn (type of spiritual creatures) and mankind to worship Him alone, to obey His commands and heed His prohibitions. Allah says [in the Quran] (interpretation of the meaning):
“And I (Allah) created not the jinn and mankind except that they should worship Me (Alone).” [51:56]
i.e., to believe in His Oneness and to devote their worship to Him alone, to the exclusion of all others. One of the conditions of worship being correct is belief in His Messenger [Muhammad] (peace and blessings of Allah be upon him) and following his example, for he is the example to be followed, as Allah says (interpretation of the meaning):
“Indeed in the Messenger of Allah (Muhammad) you have a good example to follow.” [33:21] .