We all try to avoid sin. In so doing, we grow in holiness as time goes by. We are being perfected. The final bit of sanctification upon death is the completion of that process. We call that Purgatory - a “purging” of whatever imperfections are left at the end of life, and whatever temporal punishments we did not endure due to our sins. God’s perfect justice demands the latter, and entrance into heaven where “nothing unclean” can enter demands the former.
Let me approach this another way which may clarify what I have been saying. God is a consuming fire. In fact the word Seraphim actually comes from the Hebrew which means the “burning” ones. They burn with the flame that is God because they are near God.
This is why nothing unclean can enter heaven. It would burn away in a flash in the presence of God. You can think of Purgatory as the fire of God’s love. When you die and stand before God, whatever imperfections are left in you, whatever inclinations to sin you were not able to master in this life, all this will be burned - “purged” - away in the fire of Gods love. There’s an old children’s song, “God loves you just the way you are, but much too much to let you stay that way.” Ahh, yes. Out of the mouths of babes, eh?
Picture the sequence: You become a Christian, and through your life you grow, in holiness and sancification. You sin less and less as the years pass. Just before you die, you have run a good race, but you are not yet perfect. Then you pass from this realm and stand before God, and WHOOSSHHHH, that last bit of imperfection is blasted away from you when you come into the presence of a perfection that our mortal minds cannot even fathom.
This is Purgatory: Not a place, not a second chance, but the fire of the love of the almighty eternal God.