All Christians agree that we won’t be sinning in heaven. Sin and final glorification are utterly incompatible. Therefore, between the sinfulness of this life and the glories of heaven, we must be made pure. Between death and glory there is a purification.
Thus, the Catechism of the Catholic Church states: "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. The Church gives the name purgatory to this final purification of the elect, which is entirely different from the punishment of the damned" (CCC 1030–1).
The concept of an after-death purification from sin and the consequences of sin is also stated in the New Testament in passages such as 1 Corinthians 3:11–15 and Matthew 5:25–26, 12:31–32.
The doctrine of purgatory, or the final purification, has been part of the true faith since before the time of Christ. The Jews already believed it before the coming of the Messiah, as revealed in the Old Testament (2 Macc. 12:41–45) as well as in other pre-Christian Jewish works, such as one which records that Adam will be in mourning "until the day of dispensing punishment in the last years, when I will turn his sorrow into joy" (TheLife of Adam and Eve 46–7). Orthodox Jews to this day believe in the final purification, and for eleven months after the death of a loved one, they pray a prayer called the Mourner’s Kaddish for their loved one’s purification.
Jews, Catholics, and the Eastern Orthodox have always historically proclaimed the reality of the final purification. It was not until the Protestant Reformation in the sixteenth century that anyone denied this doctrine. As the quotes below from the early Church Fathers show, purgatory has been part of the Christian faith from the very beginning.
Some imagine that the Catholic Church has an elaborate doctrine of purgatory worked out, but there are only three essential components of the doctrine: (1) that a purification after death exists, (2) that it involves some kind of pain, and (3) that the purification can be assisted by the prayers and offerings by the living to God. Other ideas, such that purgatory is a particular "place" in the afterlife or that it takes time to accomplish, are speculations rather than doctrines.