The dragon was earlier pictured (Revelation 12:4) in the labour room waiting for the woman to complete the birthing process. The dragon’s intent was to devour her newborn (and so give the lie to God’s promise in Genesis 3:15). The child, though, “was caught up to God and to his throne” (Revelation 12:5), which left the dragon deprived. This ascension of the child, Jesus Christ, to God and his throne became the catalyst for the heavenly battle described in Revelation 12:7.
7 Now war arose in heaven, Michael and his angels fighting against the dragon. And the dragon and his angels fought back,