We will start with the Four Last Things. They are Death, Judgment, Hell and Heaven. These are the things we all will face at the end of our mortal life.
It is not possible to speak of Death and Judgment without speaking of sin. It is divinely revealed truth that sins bring punishment inflicted by God's justice. These must be expiated either through sorrows, miseries or calamities in this life or else in the next life. For those who die in isolation from God due to mortal sin the Church teaches that damnation is the result. For those who, through the blessing of the sacrament of Confession, have garnered the forgiveness of their sins there is still punishment, though of a transient and purifying nature.
Christians have always understood that sin is not just a transgression of divine law but also a contempt of the friendship between God and man. It is a rejection of the love that God has shown us through Jesus Christ.
Therefore for the full remission of sins, it is necessary that not only that friendship with God be reestablished, but that also some voluntary reparation be accomplished. Sin effects not only our relationship with God but also our relationship with the whole communion of the Church. Because of this the vestiges of sin may remain to be cleansed after remission of guilt. This is clearly demonstrated by the doctrine on purgatory
1030 All who die in God's grace and friendship, but still imperfectly purified, are indeed assured of their eternal salvation; but after death they undergo purification, so as to achieve the holiness necessary to enter the joy of heaven.
1031 The Church gives the name Purgatory to this final purification of the elect, which is entirely different from the punishment of the damned. The Church formulated her doctrine of faith on Purgatory especially at the Councils of Florence and Trent. The tradition of the Church, by reference to certain texts of Scripture, speaks of a cleansing fire:
As for certain lesser faults, we must believe that, before the Final Judgment, there is a purifying fire. He who is truth says that whoever utters blasphemy against the Holy Spirit will be pardoned neither in this age nor in the age to come. From this sentence we understand that certain offenses can be forgiven in this age, but certain others in the age to come. -St. Gregory the Great
--Catechism of the Catholic Church
Sin is never a personal matter. By sin not only is the individual's relationship with God hurt, but also the solidarity of the Christian Community. However just as the sin of one harms others so to does the holiness of one benefit others. Thus the Christian faithful give each other mutual aid to attain the supernatural aim of the acceptance of salvation, which originates in Christ.
The very ancient dogma of the Communion of Saints thus explains how the efforts of both those already in Heaven, those still undergoing the purification of Purgatory and those still on Earth can be joined in the work of atonement for sin.
So we as Catholics both pray for those undergoing the purification of Purgatory and ask the saints to also pray for them. Because the most perfect prayer and worship of God is contained in the Mass we also offer Masses for the repose of the souls in Purgatory.
A mention on the term “in Purgatory.” The Church does not maintain specifically that Purgatory is a place such as Heaven or Hell or even as the physical Universe is a place. As already mentioned the word Purgatory is used to describe the process of purification that the dead, who are destined for heaven, undergo prior to their entrance to heaven. Informally it is easier to talk of individuals being in Purgatory, though it is prudent to remember that we are not necessarily talking about a concrete place.
Good works, particularly those which people find difficult can also be offered to God for the salvation of sinners. Since the sufferings of martyrs for the faith are considered of great value their work in union with Christ himself is considered to form a repository, a treasury of spiritual merit, which the Church can apply to the perennial debt owed by individuals.
This remission of the temporal punishment due for sins already forgiven is called indulgence. In an indulgence the Church is making use of its power as minister of the Redemption of Christ, which allows it to authoritatively dispense this remission from the treasury which Christ and the saints have won. This is part of the power of the Pope and the bishops to bind and loose on Heaven and Earth as successors of the Apostles.
The aim of ecclesiastical authorities in granting indulgences is not only to assist the faithful in remission of the punishment due sin but also that of urging them to perform works of piety, penitence and charity.
In the past the practice of indulgences have not always been well understood by the faithful, nor even sometimes by members of the clergy (even high ranking members.) It is forbidden to either sell indulgences or to deny their efficacy.
In the days before Vatican II it was common to talk about indulgences in term of periods of time. The object being to compare a specific indulgence to the equivalent period of penitential work by an individual. Unfortunately this practice often caused confusion among the faithful whereby it was correlated to time spent in Purgatory, which was understood to be a place rather than a process. We no longer speak of indulgences in such a way.
Instead we speak of partial and plenary indulgences. An indulgence is partial if it removes part of the temporal punishment due to sin. A plenary indulgence removes all of the temporal punishment due to sin.
Remember indulgences are only effective for removing the punishment for sins which have already been forgiven, either through the sacrament of Reconciliation for mortal sins or for venial sins through another penitential act, such as the penitential rite at Mass, saying the rosary, etc..
We can always apply an indulgence to the dead either to a specific individual or to the known or unknown dean in general as well as to the living. Specifics on indulgences are given in the Apostolic Document Indulgentiarum Doctrina.
Those who die in God's grace and friendship, once they are perfectly purified live forever with God. As it says in the CCC:
This perfect life with the Most Holy Trinity – this communion of life and love with the Trinity, with the Virgin Mary, the angels and all the blessed – is called 'Heaven.” Heaven is the ultimate end and fulfillment of the deepest human longings, the state of supreme, definitive happiness. -CCC 1024
We of our own accord do not have the power within us to enter this blessed state. It is only through the power of God manifest in the salvation brought by Jesus Christ that we can attain entrance to communion with God.
So on the Feast of All Souls remember those who are still undergoing the purification of Purgatory and pray for them.