Mormonism says that Christ overcame physical death and guaranteed physical resurrection to all mankind. But spiritual death can only be avoided by individual obedience to the commandments of God.
We believe that through the Atonement of Christ, all mankind may be saved, by obedience to the laws and ordinances of the gospel. …We believe that the first principles and ordinances of the gospel are: first, Faith in the Lord Jesus Christ; second, Repentance; third, Baptism by immersion for the remission of sins; fourth, Laying on of hands for the gift of the Holy Ghost.
—Articles of Faith, 3 and 4 (emphasis added)
Forgiveness of sins requires baptism by an approved Mormon priest. The practice of baptism for the dead is an extension of this belief, in which Mormons are baptized in proxy for those who have died without proper baptism.
The Bible says: We are unable to live a life righteous enough to meet God's standard of perfect holiness. Therefore we become right with God by faith in the work of Christ, not by our own works. Baptism and holy living are acts of obedience to God, but not a means of gaining salvation.