Question: What is Paul referring to when he mentions "baptism for the dead"?
Answer: The passage you are referring to is 1 Cor. 15:29, "Otherwise, what will those do who are baptized for the dead? If the dead are not raised at all, why then are they baptized for them?"
First, this is the only place in the Bible that refers to baptism for the dead.
Second, always look at the context before during a conclusion on doctrine. In 1 Corinthians 15, the context shows that Paul is teaching about the resurrection of the body, not baptism.
Third, the Marcionites and other heretical groups (cults) practiced baptism of the dead, but denied the resurrection of the body. Paul addresses those groups who baptized for the dead and showed how this practice contradicted what they believed about the resurrection. He said in effect, "If there is no resurrection, then why are you baptizing for the dead since according to your belief they won't be raised?"
Fourth, Paul did not endorse the practice of baptism for the dead, but distances himself from it in verse 29, "…what will those do…why then are they baptized for them." Compare that with verse 30 where he says, "Why are we also in danger every hour?"
The Church of Jesus Christ of Latter Day Saints (Mormons) are a modern-day cult that follows this practice.