Before the creation of everything, Allah created the angels. Angels were made of Nur (light) and were beings only capable of obeying Allah. They were created so they listened to eveything He told them. They were Allah's first creation of beings.
Then Allah decided to create the race of jinns. Jinns were creatures made of smokeless fire, and were created to worship Allah alone. They were able to do many things with their powers, like fly or even change shape, but could choose to do good or evil.
Even though all the jinns had a choice to do good, some of them became mischevious and started to do wicked things. They ignored Allah's command of worshipping him and started to do as they wished. This angered Allah very much.
However, there was on jinn, who's name was Iblis, who was very pious. He followed all of Allah's orders and always worshipped Him. This made him very close to Allah, and he was so pious, Allah allowed him in the company of the angels in the heavens.
Iblis became very close to Allah. Allah then decided that he would banish the jinn on the earth because of their corruption and michief in the world. Iblis also wanted to fight against these evil jinn with the angles, so Allah let him. By Allah's will, the jinn were defeated, but Allah made clear to Iblis that he was still a jinn, not an angel.
Allah then decreed he would make a creature in charge of the world after the evil jinn had gone. Iblis got happy, believing he would be in charge with all that power as a result of his devotion to Allah, like a reward, but instead, Allah shocked him by creating the first human, Adam (AS), whose race would be responsible for the earth.