Praying for the dead has basis in Scripture: “Thus he [Judas Maccabeus] made atonement for the dead that they might be freed from this sin.” (2 Maccabees 12:46) We are supposed to pray for each other, and since even death does not separate us (Romans 8:38–39), we must certainly continue praying for each other after death. Purgatory is a time of purification, since nothing imperfect can enter heaven (Revelation 21:27), and God in His mercy gives us Purgatory since few of us are perfect in this earthly life. It makes sense that we can assist our beloved dead in this process of purification by our prayers. And the Mass, being the most perfect prayer (our participation in the sacrificial prayer of Christ Himself), is the most perfect way to do this.
We have Masses said for deceased persons to assist them in their purification, to console them in this time of necessary suffering (Purgatory), and to speed their entry into heaven. We have Masses said for living persons for a variety of reasons: for their conversion, for relief from illness or other suffering, etc. God knows best what each person (living or deceased) needs, and He will use the graces obtained from celebration of Mass in whatever way He sees as most beneficial to that person.
When you offer a Mass intention for someone, it is an act of charity. Any act of charity helps us grow in holiness; when we do something kind for another person, it is as if we were doing it for Christ (Matthew 25:40), and He will judge us according to our actions and reward us. Furthermore, when we assist someone by our prayers to reach eternal happiness in heaven, they in their gratitude will certainly pray for us, and since they are near the throne of God, their prayers for our souls will be efficacious.
DISCLAIMER: Catholic Answers has turned over the archive to Catholic-Questions.org and no longer owns, manages, or moderates the forums. For additional apologetics resources please visit www.catholic.com.