First let's look at what 1 Corinthians 15:29 says: "Otherwise, what will they do who are baptized for the dead, if the dead do not rise at all? Why then are they baptized for the dead?"
The meaning is not clear from this verse itself, nor is there any similar reference in the rest of the New Testament. Some people interpret this to mean that members of the Corinthian church underwent baptism for dead people who were never converted. At least one large modern denomination follows this practice, believing that baptism on behalf of unconverted people somehow helps prepare them for a future resurrection. But the Bible says nothing about such "preparation" for resurrection. A dead person doesn't need baptism by proxy in order for God to resurrect him. That's not the purpose of baptism at all.
The context of Paul's words shows his purpose to be substantiating and verifying the doctrine of the resurrection. His meaning seems to be, "Why seek baptism (for yourself) if there is no hope of your resurrection to follow?" That is, one of the reasons Christians seek baptism is for the hope of the dead—which is the resurrection. Through baptism, they have the hope that God will one day bring them back to life—to eternal life in His Kingdom.
This explanation is consistent with the rest of the Scriptures. In Romans 6 the apostle Paul likened baptism to burial after death. Baptism is the symbolic burial of the old self, performed after a person becomes aware of and "dies" to his sin (Romans 6:1-6).
An additional truth that invalidates the idea of baptism for someone else is the fact that no one can repent for anyone else. Consequently, baptism on behalf of another person—whether the person is alive or dead—could have no bearing whatsoever on that other person's spiritual standing. Nowhere does the Bible suggest that the Church should or could baptize one person on behalf of anyone else, living or dead.
Concern for people who have died without being converted is a valid one, but God has a plan for them. The Bible reveals that God intends to bring to life (resurrect) all those who died without understanding the truth and give them an opportunity for salvation.
For more information, please read our booklet The Road to Eternal Life.