Purgatory

Purgatory in Roman Catholic theology is understood as a "place" (more correctly, a "process") where departed souls arrive if they are not judged appropriate for Heaven or Hell.

Imprecise doctrine
For many (one might argue, most) souls, it is a semi-permanent place of mild suffering where anyone who has not received the correct sacraments must wait until their as-yet unforgiven "venial" (small) sins are "set aside", making them fit enough to go to heaven. Official doctrine calls it a "State of Purification".

Critically, Catholic theology speculates that the souls of unbaptized but otherwise "sinless" children not only go to purgatory, but must remain there for an eternity but considers other possibilities. See Modern times.

Some traditions hold that all people enter purgatory briefly, as a state between death and judgement. Purgatory is generally understood as anything from a state of "eternal sleep" to being "conscious but without pain", to a mild sense of tedious displeasure. In Piers Anthony's "Incarnations" world, purgatory is a place of endless red-tape, paper pushing 9-5 ('cept 24/7) office work tedium.

In reality, pinning down what purgatory is, within the guides of Church doctrine, is about like trying to pin down what the trinity is.

Getting others out
To get your deceased relatives out of Purgatory faster, it is necessary to frequently pray the Rosary and perform other actions through which the Church grants "indulgences" (actions which have, historically, included making "donations"). You can also pay money to priests to say Masses for your departed loved ones. Naturally the RC Church is totally unmotivated by any possible financial gain but does all this solely as a service for departed souls and their relatives.

Getting yourself out
To reduce the time you have to spend in Purgatory, avoid all sins of commission, learn all the sins of omission so you can avoid them too, and confess what sins you did let slip past to a priest so you will not have so many unforgiven sins when you die. Alternatively if you can't get something past the priest, there are ways to get the church to help you on that.

Protestantism, Orthodoxy and others
Protestant doctrine generally denies the existence of Purgatory.

The Eastern Orthodox Church holds that there is an intermediate space between death and judgement, but they do not call it purgatory, and it does not hold any of the semi-permanence of Purgatory as it is understood within most Catholic doctrine, nor is it a place of "purification" or "punishment". This is one of the issues that caused the "Great Schism".

Dante
Book 2 of Dante's Divine Comedy, called Purgatorio, laid out in extravagant detail what he thought Purgatory was like. It was a 7-layered mountain, where on each layer you spent time being purged of one of the 7 deadly sins. The length of your stay on each layer depended on how sinful you were; it could last for centuries. Only when you'd purged all the sins from your soul, and then trudged through the final curtain of fire (so hot that molten glass was cooler), could you reach the summit and ascend to Heaven. Your final ascent to heaven happened because human beings naturally rise, the way air naturally rises out of the water, like in the Aristotelian sorting order of the elements; the only reason the normal people you meet on the street have weight is because they're weighed down by sin.