What is the purpose behind the creation of angels? Why Allah created them what is their purpose?
أَلَمْ تَرَ أَنَّ ٱللَّهَ يَسْجُدُ لَهُۥ مَن فِى ٱلسَّمَـٰوَٰتِ وَمَن فِى ٱلْأَرْضِ
Have you not seen that to Allah prostrates whoever is in the heavens and whoever is in the earth (https://quran.com/22:18)
so Angels prostrate to Allah, they worship him.
ثُمَّ قُلْنَا لِلْمَلَـٰٓئِكَةِ ٱسْجُدُوا۟ لِـَٔادَمَ فَسَجَدُوٓا۟
then We said to the angels, “Prostrate to Adam.” So they prostrated (https://quran.com/7:11)
So they do what Allah tells them to do.
They have some roles like holding the throne of Allah :
**وَٱلْمَلَكُ عَلَىٰٓ أَرْجَآئِهَا **وَيَحْمِلُ عَرْشَ رَبِّكَ فَوْقَهُمْ يَوْمَئِذٍ ثَمَـٰنِيَةٌ
And the angels will be on its borders. And on that Day, the Throne of your Lord will be carried above them by eight (angels). (https://quran.com/69:17)
Allah created the Angels to worship Him (by glorifying him and prostrating) , to do what he tells them to do (hold the throne of Allah, record the deeds of the servants of Allah, etc...) and they have some other roles that Allah put them in charge to do.