The Souls in Purgatory are the souls of those who died in the state of grace (i.e. as God's friends), but who are not yet cleansed enough from sin to enter Heaven. When we are sorry for our sins and confess them, God joyfully forgives us. However, each sin wounds our soul, and the damage remains even after it is forgiven. Souls who neglect to repair this spiritual damage, by doing penance, are not ready for Heaven when they die, even if they don't deserve to go to hell. So God in His mercy allows them to spend time suffering in Purgatory, in atonement for their sins before entering Heaven. The Souls in Purgatory are part of the Communion of Saints (they are sometimes referred to as "The Church Suffering"), and we have the obligation as Catholics to pray for their speedy release from Purgatory.
So Purgatory is a state of purification, where the soul can be cleansed of all the sins and damage from sin which hinder it from reaching Heaven. The fact that Purgatory exists is a proof of God's overwhelming mercy. Souls who die without having taken care to properly prepare their souls for Heaven, would actually prefer to suffer in Purgatory rather than have to enter the presence of God and stand among the glorious saints and angels, stained with even the slightest speck of sin!
The word "Purgatory", from Latin, "purgare", means to make clean, to purify.
"The fire shall try every man's work, of what sort it is. If any man's work abide, which he hath built thereupon [upon Christ], he shall receive a reward; if any man's work burn, he shall suffer loss [by the fire of purgatory], but he himself shall be saved, yet so as by fire." (1st Corinthians 3:13-15).