Before any human walked the earth, Allah told the angels that He would place a khalifah — a successor — on the earth. The angels asked, wondering, whether it would be one who would spread corruption there and shed blood. Allah told them that He knows what they do not know.
Then Allah taught Adam the names of all things. When those things were shown to the angels, they answered humbly that they knew nothing except what Allah had taught them. And Adam named them, one by one.
Allah then commanded the angels to bow down to Adam. They all bowed — except Iblis. In his pride he said he was better than Adam: he had been created from fire, Adam from clay. That pride is what drove him away from Allah's mercy.
The tree in the Garden
Adam and his wife lived in the Garden. They could eat from it freely, but they were told not to go near one tree. Shaytan whispered to them and swore that he was only a sincere adviser. Deceived, they ate from the tree, and at once felt their shame and began covering themselves with leaves of the Garden.
Iblis had erred and held on to his pride. Adam and his wife erred and turned back. They said:
Allah taught Adam words of repentance and accepted his repentance; He is the One who accepts repentance, the Most Merciful. They were sent down to the earth with a promise: guidance would come from Allah, and whoever follows it will have no fear, nor will they grieve.