Why were Angels Created?

Almighty Allah (swt) is the creator of everything in the universe. Management of His creations also belong to Him. (Arâf, 7/54) He does not need any being and helper while maintaining the order of the universe. The creation of angels does not mean that He lacks power or that He is in need of the beings in question. Because He is Samad, Who does not need anything, on the contrary, everything needs Him.  (Ikhlas, 112/2)  
Each angel is responsible for fulfilling the task given to them by Allah (swt). While some of them are in charge of writing down the deeds of people, there are also angels who only circumambulate around the Bait al-Ma'mur. Others are in charge of heaven or hell. The common aspect of all these angels is that they fulfilled the task assigned to them and offered their servitude to Allah (swt). That is, the primary duty of angels is to worship Almighty Allah (swt), to glorify Him and to praise (hamd) Him. As a matter of fact, Allah (swt) informs us that they are busy glorifying Him day and night without showing any signs of fatigue. (Anbya, 21/20) In addition, the fulfillment of some special duties by some angels is also within the scope of their obedience and worship to Allah (swt).     
Allah (swt) has not created anything in the universe in vain. Every creature, from single-celled creatures to angels, acts within the framework of the orders given to them in the universe. However, it is not possible for human beings to know the purpose of creation, reasons and wisdom of all beings. After all, Allah (swt) has not given such a responsibility to human beings. In addition, servants try to perceive or comprehend the wisdom of beings and objects in the universe with the blessing of mind given to them. In many verses of the Qur'an, it is ordered to take lessons from them by looking at what is happening around us and to contemplate on their creation.  
There is hikmah in the creation of everything. Thanks to the mind given to him, a person can sometimes think about hikmah. However, it would be wrong to say that what is thought is the will of Allah (swt). Because this situation is the area of ghaib for human beings. People have no knowledge of the ghaib. 
Knowing the nature or essence of objects or things in proportion to one's power is called hikmah. Hikmah, which is beyond the control of man's power and will, has been defined as "divine hikmah". (İlhan Kutluer, “Hikmet”, DİA, XVII, 503-511) In this respect, the creation of angels is also a matter of "divine hikmah". It is possible to put forward ideas about them, but whether these ideas are true or not is within the knowledge of Almighty Allah (swt).

6