In 1 Corinthians 15:29, Paul writes, "What do people mean by being baptized on behalf of the dead? If the dead are not raised at all, why are people baptized on their behalf?" The phrase "on behalf of the dead" is not actually in the Greek. The Greek word can mean "for" or "for the sake of," not necessarily "on behalf of."
Paul has been discussing the resurrection of the dead, and he brings up this custom of which we know little to help make his point. The Navarre Bible ("Corinthians," 148) explains:
[Paul] makes reference to a strange custom that implicitly indicates belief in resurrection. No other source provides information about this custom, and therefore it is not possible to say exactly what it involved. . . . The apostle is neither approving [nor] condemning this custom; he is simply saying that it demonstrates Christian belief in the resurrection of the dead.
It is not clear that Paul envisioned one person being baptized in the place of a dead person. He may have meant something else, such as being baptized in order to be united with one’s Christian loved ones who had died.