Why Did Allah Create Iblis?
Ibnul Qayyim al-Jawziyyah, in his Shifaa’ al-‘Aleel, gives some of the wisdoms underlying Allah’s creation of Iblis:
1) Falling under the servitude Muslims must show to Allah is seeking to oppose Iblis and seeking refuge in Allah from his evil. Thus, the opportunity to resist Iblis further complements the glorification of Allah.
2) The believers and the angels would fear for their own fate and be wary of their own actions after witnessing and hearing about what happened to Iblis’s fate after disobeying Allah.
3) As the father of the human race, Allah made Prophet Adam (peace be upon him) an example and lesson for all human beings to reflect upon and consider so that when we disobey Allah, we seek repentance. Similarly, Allah made Iblis an example and lesson for the rest of jinn, as the father of the Jinn race, to consider and fear the consequences of disobeying Allah.
4) Iblis is used as a test by Allah to separate and distinguish those pious human beings from those who are evil, as Allah did say, “Allah would not leave the believers in that [state] you are in [presently] until He separates the evil from the good.” [3:179]
5) The creation of Iblis is a demonstration of Allah’s Power to create whatever He wishes, particularly things which stand in contrast to one another such as the heavens and earth, darkness and light, heaven and hell, water and fire, heat and cold, good and evil, etc.
6) The creation of evil such as Iblis makes one appreciate the goodness and beauty of what is polar to it so that the good is more highly appreciated for its intrinsic beauty.
7) Some of Allah’s names are: 1) Al Khaafidh (الخافض) The Abaser, The Demeanor, 2) Al Muzil (المذل) The Humiliator, 3) Al Muntaqim (المنتقم) The Avenger, etc. Such creatures as Iblis should ideally exist so that Allah manifests and enacts these attributes upon them with justice.
Allah knows best.