Why is Satan going to be let loose for a short time at the end of the Millennium?
The passage you are referring to is found in Revelation 20.
When the thousand years are completed, Satan will be released from his prison, and will come out to deceive the nations which are in the four corners of the earth, Gog and Magog, to gather them together for the war; the number of them is like the sand of the seashore. (NASB) Rev. 20:7-8
Satan rebelled against God either before the creation of the world or shortly after Adam and Eve were created. He is now god of this world (2 Cor. 4:4), and he prowls about after us like a lion (1 Pet. 5:8). He is the ruler of this world (John 12:31; 14:30) and the prince of the air (Eph. 2:2). When the Tribulation arrives, he will attempt to defeat God in a battle which he will lose. As a result, God will put him into a prison called the abyss. Satan will be released from the abyss after being bound in prison for 1,000 years. When he is released, he will not repent and seek God’s forgiveness. This wicked angel will have no sorrow, no remorse, and no regrets after 1,000 years in a place where he did not want to be. Yet, he will try it all over again. He will deceive the non-Christians of the world, and bring them to Jerusalem in an attempt to defeat God. God will destroy the armies of the world with fire.
And they came up on the broad plain of the earth and surrounded the camp of the saints and the beloved city, and fire came down from heaven and devoured them. And the devil who deceived them was thrown into the lake of fire and brimstone, where the beast and the false prophet are also; and they will be tormented day and night forever and ever. (NASB) Rev. 20:9-10
Why did God allow Satan to be released? To prove to every created being that Satan would not repent of his wickedness even after 1,000 years in prison. The release of Satan will also motivate those on the earth to reveal their true sinful hearts. The bigger question is, “Why will the people of the world reject God?” There was peace in the kingdom. Life was wonderful, but they did not like God’s moral law because they did not love Him. It appears that God will allow this to occur in order to prove how evil men and women really are. Men and women love their sin, and they hate God. This rebellion after the wonderful kingdom will be just one more justification for God sending everyone who rejects Jesus to the Lake of Fire.
We must not forget that God loves all of His created beings. But a holy God must eventually punish self-centered beings who will not repent of their sins. Yes, God loves us, but He is also holy and just.