When the soul that has been created for a human has been placed, the angels were asked to then prostrate.
The heavens and even the mountains were asked to accept the agreement brought to humans and both refused to hold the responsibility as they were afraid.
Humans were unjust and ignorant and took on the covenant.
The Lord of the worlds is Most-Wise, it is fair to say that He knew of the disobedience of the shaitan before it actually came.
When he, the devil committed the act of disobedience, he only tried justifying his disagreement, whereas Adam (PBUH), the first human form, as soon as the mistake was made, he stated to the Lord of the worlds, that without forgiveness, indeed, that he, Adam (PBUH) would be lost and among the losers.
The Lord created the heavens and the earth in six days and then established Himself above the throne, over all of creation.