God selected John the Baptist for a special purpose – to prophecy that The Messiah was coming and that mankind should repent.  The Bible does not say why John the Baptist’s life was not spared, but we can reason that his death was according to God’s will and plan.  We know Jesus was capable of protecting John, but would never do something against God’s will.  In the case of His own life, Jesus said He could call upon an army of angels to protect Himself (Matthew 26:53-54). Of course, this was not the Heavenly Father’s will.  Jesus needed to be a willing sacrifice to serve as a ransom and take away the sins of the world.

We can conclude something similar in the case of John the Baptist.  Certainly, Jesus had the capability to call upon legions of angels or use miraculous means to save John.  However, that was not part of God’s plan. 

A better question may be, what was God’s purpose for John the Baptist’s life?  He was meant to prophecy the coming of the Messiah and lead the Jewish people to Him (Jesus).  As a result of John’s death, some of his followers came to follow Jesus – certainly this was part of the plan that God had in mind, as there would be no mistaking that Jesus was the Messiah and that John was the final prophet to point his fellow Jews to follow Jesus.  He was the last of the prophets, and we think he will be included with those faithful ones that are given a better resurrection (Hebrews 11:35).