As ever, Cosmas sweeps onto the scene to undo the damage of Damian. I'll be explaining purgatory from my perspective.
Firstly, we should understand the biblical basis for purgatory. Some try to place it in Christ's teachings, but this is quite difficult. The main passage is, as always, in Paul:
"For other foundation can no man lay than that is laid, which is Jesus Christ. Now if any man build upon this foundation gold, silver, precious stones, wood, hay, stubble; Every man's work shall be made manifest: for the day shall declare it, because it shall be revealed by fire; and the fire shall try every man's work of what sort it is. If any man's work abide which he hath built thereupon, he shall receive a reward. If any man's work shall be burned, he shall suffer loss: but he himself shall be saved; yet so as by fire."
Yes, I am aware that this is a heretical translation.
One way to think of purgatory then is this: Perfect faith brings forth perfect works, perfect works point to perfect faith. Purgatory is God's mercy compensating for our own failings.
Purgatory is not the remnant of some kind of dodgy works-salvation theology, whereby we have to pay the price of the broken window, as Damian puts it. This is not biblical.
The role of purgatory can also be put into these terms: Sin has three consequences: It separates us from God; we enter a debt to goodness that we cannot pay; and it taints us, preparing us to sin further.
Purgatory is not the paying of the debt to goodness.
The separation from God is healed by his omnibenevolent forgiveness. "Man, your sins are forgiven you." Luke 5:20b.
The debt to the transcendent Good is paid for by the Holy Cross of Christ. "You know that you were ransomed (redeemed/paid for) from the futile ways inherited from your fathers, not with perishable things such as silver or gold, but with the precious blood of Christ, like that of a lamb without blemish or spot." 1 Pet 1:18-19
The taint of sin is removed by the obedience of faith, and it is this which, when left incomplete by us, is finished by God's mercy in the fires of purgatory.
Protestants often criticise the doctrine of purgatory for the reason that it seems to promote works salvation. This is not true. When properly understood, it is absolutely biblical.
The Catholic Church requires of believers relatively little regarding what purgatory is like. Drawing from Isaiah 6:5-7. I understand it to be a personal encounter, whereby the soul meets the Lord and is purged by the burning, passionless passion, which is love divine. When we behold him face to face, we become perfect. This links back to my first way to understand purgatory. Perfect faith means that man behold God as he is, and hence brings forth perfection. At the moment of death, faith is abolished and we behold God as he is, and this makes us perfect.