Why Was Iblis Commanded to Prostrate to Adam?
Question

If Iblis was not one of the angels, why was he commanded to prostrate to Adam along with the angels?
Praise be to Allah.Undoubtedly, when Allah, may He be Exalted, commanded the angels to prostrate to Adam , this command was also addressed to Iblis, as Allah, may He be Exalted, says (interpretation of the meaning):
“…except Iblis (Satan), he refused to be of those who prostrate.(Allah) said: `What prevented you (O Iblis) that you did not prostrate, when I commanded you?’” (Al-A`raf 7:11-12] 
The scholars have spoken about the reason why the command to prostrate to Adam was addressed to Iblis even though he was not one of the angels ; they stated that the reason for that was that he was similar to the angels in their outward deeds. 
Ibn Kathir (may Allah have mercy on him) said (1/105): 
The conclusion is that when Allah, may He be Exalted, commanded the angels to prostrate to Adam, He included Iblis in that because, even though he was not one of them , he was imitating them and doing deeds like theirs. Hence he was included in what was addressed to them, and he was condemned for going against the command.” 
Shaykh Ibn `Uthaymin (may Allah have mercy on him) said in Tafsir Surat Al-Baqarah (1/127): 
“If someone were to say: there is something confusing in this verse, which is that when Allah, may He be Exalted, says that He commanded the angels to prostrate, He says that they all prostrated except Iblis, and it would appear to mean that Iblis was one of them, but that is not the case. 
The answer to that is that Iblis shared with them their outward deeds, so the command included him on the basis of his outward deeds.”
Something similar was also said by At-Tahir ibn `Ashur (may Allah have mercy on him) in his Tafsir, At-Tahrir wat-Tanwir (1/409). 
What we are obliged to believe is that the command to prostrate to Adam was addressed to Iblis just as it was addressed to the angels, and this is what the Quran clearly says (interpretation of the meaning):
“(Allah) said: `What prevented you (O Iblis) that you did not prostrate, when I commanded you?’” [Al-A`raf 7:12] 
As for the reason why this command was addressed to him, Allah knows best. 
And Allah knows best.