Catholics believe that purgatory exists and is a state in the afterlife that prepares souls to enter the heavenly bliss of eternal life.
Who goes to purgatory?
Purgatory is not meant for everyone who dies, but only those souls that need further purification and preparation for Heaven.
The Catechism of the Catholic Church gives the following definition:
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 Catholic Encyclopedia offers a similar definition, calling purgatory "a place or condition of temporal punishment for those who, departing this life in God's grace, are not entirely free from venial faults, or have not fully paid the satisfaction due to their transgressions."
Essentially this state is reserved to people who want to enter the gates of Heaven, but who still had some attachment to earthly things.
Some have used the following example. At baptism we are given a white garment and at our death, we are to present to God that same white garment unstained. However, if that garment still has a few stains on it, it needs to be purified. In this example purgatory is seen more like a laundry, where you go to purify that white garment.
Souls that are able to present that white garment without any spot or wrinkle are able to enter Heaven immediately.
On the other hand, souls that do not want to be in the presence of God and who freely reject him are not allowed to enter purgatory and freely choose to enter Hell.
Purgatory is not a place everyone goes, but it exists through the Divine Mercy of God, who offers us a state to pass through where we can be purified before we reach the glory of Heaven.