This prayer was composed by Pope Leo XIII. He wrote it after experiencing a vision that showed the battle between between the Church and Satan. In 1886, this prayer and the Hail Holy Queen (Salve Regina) were to be recited at the end of the “low” Mass (“low” meaning the Mass that was spoken, with no music, compared to the “high”, or sung Masses). This practice was discontinued around 1970.
In April 1994, during the International Year of the Family, Pope John Paul II during his Regina Coeli message asked all Catholics to pray this prayer daily. We invoke the help of St. Michael in our struggle against Satan and sin.
Catholic Encyclopedia – St. Michael the Archangel
One of the principal angels; his name, “Who is Like Unto God”, was the war-cry of the good angels in the battle fought in heaven against the enemy and his followers.
St. Micahel & All Angels
Now war arose in heaven, Michael and his angels fighting against the dragon; and the dragon and his angels fought, but they were defeated and there was no longer any place for them in heaven. And 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. — Revelation 12:7-9 [RSV]