That verse is in the context of a larger argument on resurrection. It's largely in response to the question posed in verse 12: "Now if Christ is proclaimed as raised from the dead, how can some of you say that there is no resurrection of the dead?" Paul goes on to prove resurrection.
In v29, Paul is NOT arguing for the practice of the baptism of the dead. That is no where commanded in Scripture and he's not condoning it. He is merely referring to other people who do practice it, and he's arguing that even they have hope of resurrection. If they didn't (he's arguing), why would they baptize the dead? It would be a practice in vain.
It's just one argument among many for the reality of the resurrection.
Hope this helps.
Tom