Why pray for those who have died ?
Even when someone dies in a state of grace (that is, in a fundamentally sound relationship to God), there may still be excess spiritual "baggage" in his or her life. He/She may hold an unresolved grudge or they may yet struggle with jealousy. While these imperfections have not destroyed their relationship with God, they still are inhibiting factors which must be resolved prior to their complete enjoyment of life with God in Christ. Thus, purgatory gives us such an opportunity. Purgatory, is state of post mortem purification, which exist; and it is of benefit to those souls who are experiencing purification that we remember them in prayer, particularly at the Eucharistic celebration
Inasmuch as we encourage others to pray for us in this life, it only makes sense that we can hope for their prayerful support after we die. Essential to the Catholic understanding of the Church is the doctrine of the communion of saints: we share a "connectedness" or fellowship which transcends death. And so while I can pray for someone's struggles in this life, I can surely do so for them after death.

Msgr. M Heintz