If you have ever tried to trace down your family roots, chances are someone recommended using the genealogical resources at your local Mormon church. It is not bad advice at all as the Church of Jesus Christ of Latter Day Saints maintains one of the largest databases of ancestry information in the world. What many people who use the resources may not know is why such information may be kept on file.
In recent years the church claiming twelve million members has come under fire for baptizing dead victims of the Holocaust and has been asked twice not to do it. Once in 1995 and again in 2002. After the death of Pope John Paul II, his birth name was quickly found on a database designed to keep track of ancestry. Whether or not he has been baptized and thus achieved sainthood rather earlier than he would have as a Catholic is unknown.
If you search around the Internet you can find sites claiming people ranging from the Buddha to Hitler are now Mormons in the afterlife with the credibility of them varying greatly. Still, while such musings are entertaining it does not answer the question as to why the practice exists to begin with. The answer lies, as you may suspect in their theology and view of the afterlife.
A strong point of the religion and one they could sell more readily other than the belief that you can become a god, is that it is not quick to condemn anyone to eternal punishment. Only those people who deny or betray Christ such as Judas Iscariot will find themselves languishing in outer darkness. Even former members are safe so long as they have not seen God or Jesus.
When the spirit departs from the body there are one of two possible destinations where people wait until judgment and the morning of the resurrection. Those who accepted Christ as their Savior and did basically lead a good life wind up in Paradise. Those who failed to do so will find themselves in a Spirit Prison. However, being good individuals, the souls in the temporary Heaven will go and rescue the lost souls. Because baptizing is necessary for the soul to enter into higher degrees of glory and because baptizing can only be conducted on Earth, Mormons in good standing can go into the temples and stand proxy for the deceased.
An important part of this process is that the soul who receives this treatment is not required to accept, even though the process and repentance for whatever sins you committed in this life earns you Terrestrial Glory, something higher than what you otherwise might have achieved. A full discussion of where you might end up in Eternity can be found in the Doctrine and Covenants, Section 88.
While many people may find it offensive, the intentions of the Mormons are actually good, although critics point out that it is pointless busywork designed to keep members from thinking about the doctrine too much. The examples mentioned above of holocaust victims miss an important point, many of the people who died in the concentration camps did not leave descendants and should not appear on the Mormon roles. However, most of the temple workers are senior citizens who volunteered to server a mission and perhaps can be forgiven for not policing the rolls so strictly.