Rev 20:2-3 And he seized the dragon, that ancient serpent, who is the devil and Satan, and bound him for a thousand years, (3) and threw him into the pit, and shut it and sealed it over him, so that he might not deceive the nations any longer, until the thousand years were ended. After that he must be released for a little while.
Rev 20:7-8 And when the thousand years are ended, Satan will be released from his prison (8) and will come out to deceive the nations that are at the four corners of the earth, Gog and Magog, to gather them for battle; their number is like the sand of the sea.
The book of Revelation is symbolic. The beast and the dragon represent national powers. This can be seen from Rev 13:
Rev 13:1-4 And I saw a beast rising out of the sea, with ten horns and seven heads, with ten diadems on its horns and blasphemous names on its heads. (2) And the beast that I saw was like a leopard; its feet were like a bear’s, and its mouth was like a lion’s mouth. And to it the dragon gave his power and his throne and great authority. (3) One of its heads seemed to have a mortal wound, but its mortal wound was healed, and the whole earth marveled as they followed the beast. (4) And they worshiped the dragon, for he had given his authority to the beast, and they worshiped the beast, saying, “Who is like the beast, and who can fight against it?”
This description is a composite of the beasts of Daniel 7, where an interpretation is given:
Dan 7:17 These four great beasts are four kings who shall arise out of the earth.
So the beast and dragon are political powers.
God has chosen to given humankind the ability to choose between right and wrong. What is it that deceives people into choosing the wrong way? This is not just an academic question. If we blame an external malevolent person when the real culprit is our own human wickedness then we are making a serious mistake. Satan has been discussed on this site before:
So why does God “loosen Satan for a time”? In other words, why will God allow human wickedness to become influential after a period of suppression? The reason why God ever allows human wickedness is so that God has given us freewill. He did not create us as robots. Why God will suppress and then release wickedness specifically at that time I don’t know.