Surah 2 verses 30-39
30. Behold, your Lord said to the angels; I will create a vicegerent (representative) on earth." They said : "will you place therein one who will make mischief therein and shed blood?--While we do celebrate your praises and glorify your Holy (name)?" He said: "I know what you know not"
31. And he taught Adam the name of all things; then he placed them before the Angels and said: "Tell me the names of these if you are right."
32. They said: "Glory to you: of knowledge we have none, save what you have taught us: In truth it is you who are perfect in knowledge and wisdom."
33. He said: "O Adam! tell them their names." When he had told them their names, God said: Did I not tell you that I know the secrets of the heaven and earth and I know what you reveal and what you conceal?"
34. And behold, We said to the Angels Bow down to Adam:" and they bowed down: Not so Iblis, he refused and was haughty. He was of those who reject faith.
35. And we said: "O Adam, dwell you and your spouse in the Garden; and eat of the bountiful things therein as you will, but approach not this tree, or you run into harm and transgression." 36.Then did Satan make them slip from the (Garden), and get them out of the state (of felicity) in which they had been. And we said "Go down all (you people) with enmity betwen yourselves. On earth will be your dwelling place and your means of livelihood for a time."
37. Then learnt Adam from his lord certain words and his Lord turned towards him; for he is oft Returning, Most Merciful.
38. We said: "Go down you all from here; And if, as is sure, there comes Guidance from me, whosoever, follows my Guidance , on them shall be no fear, nor shall they grieve.
39. "But those who reject faith and reject our signs, they shall be companions of the fire; They shall abide therein.
'The movement which is the existence of the Universe is the movement of love"----Ibn Arabi
Why did God create? Perhaps the words "The Most Compassionate, The Most Merciful" at the start of every Surah hold a clue. As Ibn Arabi points out, God creates from Love. Perhaps a love so great, so vast, inevitably overflows and is manifested as the created, the finite. We are all from God and we will all return to God. But creation is an act of division, of becomming apart from God the Infinite, the Uncreated.
The story of Adam (pbuh) does not begin with his creation--but with a dialogue between God and his Angels. God reveals his plans for a representative who will manage his creations on earth. The Angels, who perfectly carry out God's will, ask how a creation so imperfect ("one who sheds blood"/has free-will) would manage such a task---when they themselves do it so well. God does not answer the question directly but proceeds to demonstrate the answer. He teaches Man and then places them in front of the Angels, asking them to inform him of the nature of Man. The Angels cannot for they have no knowledge. Then God turn to Man and asks them the nature of Angels---and Man answers. The Angels have limitations because they are only able to carry out to perfection God's will, they have no potential for imagination. But Man has free-will and his potential is limited only insofar as his self-imposed limits to his imagination. It is in this creative power of the imagination that Man becomes better than the Angels.
But, God does not send Mankind directly to earth. Though Mankind is supposed to be a vicegerent on earth, God nurtures him to maturity in the Garden for a while. Why? Because Mankind has yet to demonstrate his ability to use free-will. God gives the instructions to not approach a certain tree and Satans tempts Mankind. At this point Mankind has a choice---he can choose of his own free-will not to approach the tree in spite of Satan---or to choose of his own free-will to be tempted. This excercise of free-will catapults Mankind into the role he was created for---to do God's will on earth. But the choice of Mankind has consequences, for instead of excercising free-will to refrain from temptation, Mankind excercised it to fall into temptation.
Yet, God is most Compassionate, most Merciful and forgives those who repent. Mankind is forgiven and promised Guidance. But with the blessings of free-will comes the responsibility. We must all choose of our own free-will to follow Guidance or to reject it just as Adam(pbuh) did. Our life on earth is not a gift or a punishment---it is a test/trial. God has empowered us, through our free-will, to choose our ultimate destiny---Paradise or Hell.
Those souls who enter Paradise are gently cleansed, while those souls who enter Hell are cleansed fiercely---in the end all creation returns to God.....to Unity.
"That is why the love of the Tao is in the very nature of things" Lao Tzu
"It is he who is revealed in every face, sought in every sign, gazed upon by every eye, ....Not a single one of his creatures can fail to find him in its primordial and original nature." Ibn Arabi.