Indulgences became increasingly popular in the Middle Ages as a reward for displaying piety and doing good deeds, though, doctrinally speaking, the Church stated that the indulgence was only valid for temporal punishment for sins already forgiven in the Sacrament of Confession.
(this is a sample answer)
Hope this helps! <3