Our Gemara on amud beis discusses how a son cannot bring his father’s sin offerings in his place.  The basic idea is Ein Kapparah Lamesim, people who are dead cannot have atonement via the offerings of their descendants.  (See Horiyos 6a, Commentary of Tosafos Harosh ibid “veha”, Rashi Meilah 10b “Velad”.)  While this has been stated in terms of the ritualary aspect of sacrifices, we all know from lived Jewish life that we believe the descendants achieve some kind of forgiveness or merit for the deceased relatives.  

Beis Yosef (OH 621:15) quotes a Sifra and a Mordechai that the custom of pledging tzedakah on Yom Kippur is to atone for the deceased. Rama adds to this (Ibid OH 621:6): Even mentioning the deceased’s name (Yizkor) somehow brings atonement. 

It is logical to say that only when we are alive, and making our own choices can we bring merit or obtain forgiveness. How then, can we explain this process of others effectuating atonement for those in the next world?  Taz (ibid 4) and Magen Avraham (ibid 6) explain that God knows the person would have given the charity if he could have, so it counts as a merit. Presumably, Taz is saying since some of the money is inherited, it is as if the deceased gave it.  Mishna Berura (ibid 19) adds that since this is based on an assumption that the person would have wanted, this will not help obtain forgiveness for an avowedly evil person, unless he perhaps repented on his deathbed. He also adds, perhaps a son, who has a special place as his father’s agent, could somehow even obtain forgiveness for a father who was unrepentant.  The psychological justification for this might be that whatever good the child does, must somehow relate to some positive influence of the father.  (After all, even the forefathers were careful to marry into their families (Lavan and Besuel), despite their evil and corruption, as there must have been in those families relatively admirable qualities than the other barbarians.) Therefore, any good deed done by a direct descendant can be at least partially attributed to the actions and the merits achieved by the deceased in his lifetime.   

Yizkor and Kaddish are staples of Jewish life and have also remained a tradition by those who otherwise are not even religious. This indicates a deeply held belief, that above all, when it comes to investing in the afterlife, even the less religious will hedge their bets. If there are no atheists in fox holes, kal v’chomer, there are no atheists in the grave.