The question of purgatory and praying for the dead was a major issue between Catholics and Protestants in the 16th century. The Council of Trent’s 1563 decree about purgatory reaffirmed its existence and the usefulness of prayers for the deceased, yet it cautioned against “a certain kind of curiosity or superstition...” about it.
The Roman Catholic teaching on purgatory reflects its understanding of the communion of saints. We are connected to the saints in heaven, the saints-in-waiting in purgatory and other believers here on earth. Prayers for the deceased are not a means of buying their way out of purgatory.
The Catholic Church’s teaching about purgatory (Catechism of the Catholic Church, #1030-32) says that all sin, unfortunately, has a life of its own and may have bad effects even after the sinner repents. Sincere repentance includes a desire to repair the damage done by one’s sins. That may or may not be complete before the person dies.
When the world ends at the Final Judgment, there will be only two possibilities: heaven and hell. We who celebrate Jesus’ Resurrection over sin and death look forward to sharing in that victory, and we pray that our beloved dead may do the same.