Mormonism teaches that the spirits of all people will go to a spirit world after death. Mormon spirits will go to paradise. Here they will continue their eternal progression towards godhood.
Spirits of non-Mormons will go to a place of hell and punishment called spirit prison. Here, they receive a second chance to learn the true LDS gospel via spirits from paradise doing mission work. Spirits in spirit prison who accept the LDS gospel and repent of their sins hope that a Mormon will go to the LDS temple to be baptized for them and carry out other ordinances on their behalf. Without this happening, they will not be able to enter paradise. “Those in spirit prison have the opportunity to learn the gospel of Jesus Christ, repent of their sins, and receive the ordinances of baptism and confirmation through the work we do in temples (D&C 138:30-35). When they do, they may enter paradise” (True to the Faith, p. 111).