Although not one of the Four Last Things, purgatory fits in with the last things because for most good people, it will be experienced somewhere between judgment and heaven. The existence of purgatory is taught by the Church because it has some Biblical basisand it is a logical way of upholding the belief that God is both merciful and just.
There can be no evil or attachment to sin in heaven. Consequently, that would leave most humans in hell if not for the place of cleansing. Purgatory is a place that purifies a soul in preparation for communion with God in heaven. For people who die in a state of sin (not mortal), purgatory is a place of hope because however long or painful the cleansing is, it is only temporary and the joy of heaven waits beyond.