Answer
Satan was originally one of God’s holy angels, but he rebelled against God and was cast out of heaven «And he said unto them, I beheld Satan as lightning fall from heaven. », (Luke 10:18). That was only the first stage of his judgment. Satan’s kingdom was vanquished at the cross (John 12:31-32). Later, he will be bound in the abyss for one thousand years (Revelation 20:1-3) and then will be cast into the lake of fire for eternity «And the devil that deceived them was cast into the lake of fire and brimstone, where the beast and the false prophet are, and shall be tormented day and night for ever and ever. », (Revelation 20:10).
Until his final judgment, Satan is known as “the prince of this world” «Hereafter I will not talk much with you: for the prince of this world cometh, and hath nothing in me. », (John 14:30), but it seems that he still has restricted access to the heavenly realms. In Job 1:6, Satan stands in the presence of God. A similar situation is found in 2 Chronicles 18:18–21 involving a “lying spirit.”
Since God is holy and absolutely without sin «And one cried unto another, and said, Holy, holy, holy, is the LORD of hosts: the whole earth is full of his glory. », (Isaiah 6:3), and since He will not even look on evil «Thou art of purer eyes than to behold evil, and canst not look on iniquity: wherefore lookest thou upon them that deal treacherously, and holdest thy tongue when the wicked devoureth the man that is more righteous than he? », (Habakkuk 1:13).
Wicked devoureth the man that is more righteous than he?”, (Habakkuk 1:13), how can Satan be in heaven? The answer involves God’s sovereign restraint of sin. In Job 1, Satan stood before God to give an account of himself. God initiated the meeting, led the proceedings, and remained in absolute control (verse 7). The result was that Satan’s power was limited (verse 12) and God was glorified.
Here are some other facts to note: 1) Satan does not have open access to God’s presence. He is summoned by God. 2) The visits are temporary. His time before God’s throne is limited. 3) In no way is the purity of heaven tainted by the brief, God-ordained presence of a sinful being, “quarantined,” as it were, by God’s regulatory power. And, 4) Satan’s access is only granted prior to the final judgment. After the judgment, God creates a new heaven and new earth “And I saw a new heaven and a new earth: for the first heaven and the first earth were passed away; and there was no more sea.”, (Revelation 21:1), wipes away all tears from our eyes (verse 4), reveals the New Jerusalem (verse 10), and promises the complete absence of sin (verse 27).
When we say, “God cannot allow sin into heaven,” we simply mean that God cannot allow human beings who are still in their sin to live in His presence. But it is possible for God to command a sinful being to stand (temporarily) in His presence in order to commission him (Isaiah 6), to exact an account from him (Job 1-2), or to judge him (Revelation 20:11-15) without compromising His holiness.
God’s holiness will eventually consume all sin. Until that day, His holiness regulates sin, and that means that Satan, on certain occasions, is briefly summoned before his Creator to give an account of his actions.