Why did God create the angels? What was His purpose behind it?
We might not know it, but there are angels all around us, at least those of us who have trusted in Christ. Like everything else, angels were created for a purpose or God wouldn’t have created them in the first place. God never does anything without purpose. The word angels means “messenger of God” and comes from the Greek word “ángelos.” Angels are spirit beings that can take on human appearance at God’s command, but they can also be used by God as His agents for judgment. Even though we can’t see them, we might have encountered them in our lives as they might appear to be strangers. This is why the author of Hebrews wrote a warning to “Do not neglect to show hospitality to strangers, for thereby some have entertained angels unawares” (Heb 13:2). Lot was visited by angels  to warn him and his family of the coming judgment on Sodom but when some of the wicked men tried to take advantage of these men (really, angels) for sexually immoral purposes, they were struck blind.
Angels are holy beings, all except those that rebelled with Satan and who have since became demons. They have the same power as holy angels but they cannot do more than God allows them to do (Job 1:12). On one occasion, when some of the apostles were in prison for preaching the gospel, “an angel of the Lord opened the prison doors and brought them out, and said, ‘Go and stand in the temple and speak to the people all the words of this Life’” (Acts 5:19-20) and on another occasion, “an angel of the Lord stood next to him, and a light shone in the cell. He struck Peter on the side and woke him, saying, ‘Get up quickly.’ And the chains fell off his hands” (Acts 12:7), so angels do what God commands them to do and no chain or prison bars or doors is too difficult for them to break. During the period of the early church, “On an appointed day Herod put on his royal robes, took his seat upon the throne, and delivered an oration to them. And the people were shouting, “The voice of a god, and not of a man” (Acts 12:21-22), but then, “Immediately an angel of the Lord struck him down, because he did not give God the glory, and he was eaten by worms and breathed his last” (Acts 12:23). Don’t think that God doesn’t take His glory seriously because He won’t share His glory with another (Isaiah 42:8), especially an ungodly king who refused to give God the glory and made himself out to be like God.
If you want to know more about angels, I strongly suggest you read Hebrews chapter one because there are dozens of references to angels and their specific purposes. God has declared that “He makes his angels winds, and his ministers a flame of fire” (Heb 1:7). The psalmist said much the same thing when he wrote that God “makes his messengers winds, his ministers a flaming fire” (Psalm 104:4). The angels came after Jesus’ temptation in the wilderness as it says, the “angels came and were ministering to him” (Matt 4:11). Jesus had a multitude of angels at His disposal. All He needed to do was to command them to appear and they would, because Jesus is God and is sovereign over the angels too (Luke 22:43). If you have trusted in Christ then “he will command his angels concerning you to guard you in all your ways” (Psalm 91:11), since they are “his ministers, who do his will” (Psalm 103:21), and speaking of their power, the psalmist says of “his angels, you mighty ones who do his word, obeying the voice of his word” (Psalm 103:20).
There are angels around the throne of God that do nothing but praise Him, 24/7. The reason God created these angels is that they might give Him praise, honor, and glory, and they are doing that right now, as you read this. Isaiah wrote more about the holiness of God than any other author in the Bible and he “saw the Lord sitting upon a throne, high and lifted up; and the train of his robe filled the temple” (Isaiah 6:1), and over the throne of God, there were “seraphim. Each had six wings: with two he covered his face, and with two he covered his feet, and with two he flew. And one called to another and said ‘‘Holy, holy, holy is the Lord of hosts; the whole earth is full of his glory’” (Isaiah 6:2-3). That is all they do, all the time. They proclaim what is true and that is that God is holy, holy, holy. In the Jewish culture, when something was repeated three times, it was the greatest emphasis that was possible to give something, and here it’s about God’s holiness. One angel covered their eyes symbolizing that no one can look directly at God and live. The other angel covered their feet which is symbolic of their being on holy ground, similar to what God told Moses (Ex 3:5), and the commander of the Lord’s army told Joshua; take off your shoes for you’re standing on holy ground (Joshua 5:15).
Are there Guardian Angels?
If there are guardian angels , I’ve never seen it precisely named as so in the Bible, but I do know that God has dispatched his holy angels as ministers and they are to minister to believers (Heb 1). It appears that there may be angels who keep watch over children too (Matt 4:6). Several times angels came to rescue the apostles who were in prison, but sometimes they brought messages directly from God (Dan 10), so angels are more than just guardians…they are God’s messengers, and do what He commands them to do. No angel ever walked contrary to the will of God or ever deviated from what God told them to do. Angels never work independently of God. Only Satan, a fallen angel, and those who followed him in his rebellion, acted independently from God, but even these can do no more than God allows. Satan and his demons rebelled against God (Luke 8:31), but that rebellion will end someday (Rev 20:7-10).
Satan and his fallen angels continue to harass Christians today, and even though they can’t take a human life, they can send us waves of spiritual attacks (Eph 6:11-12). When Satan fell, he fell hard, because he wanted to take over God’s throne and receive worship like God does, but “the great dragon was thrown down, that ancient serpent, who is called the devil and Satan, the deceiver of the whole world—he was thrown down to the earth, and his angels were thrown down with him” (Rev 12:9). The time is coming (soon?) when the world will be judged and God “will send out his angels with a loud trumpet call, and they will gather his elect from the four winds, from one end of heaven to the other” (Matt 24:31) and then, “When the Son of Man comes in his glory, and all the angels with him, then he will sit on his glorious throne” (Matt 25:31). Its sin to worship angels but also to become preoccupied with them; rather we should be preoccupied with Jesus Christ Whom even the angels worship and so should we.
More about angels here: What Do Angels Look Like? 
Resource – Scripture quotations are from The Holy Bible, English Standard Version® (ESV®), copyright © 2001 by Crossway, a publishing ministry of Good News Publishers. Used by permission. All rights reserved. Photo rendered from Logos Bible Software 6.0 Visual Copy.