According to the LDS Church, the practice of baptism for the dead is based on a revelation received by the prophet Joseph Smith.
Initially, women could be baptized for dead men, and vice versa; this, however, was changed in order to ensure that the person being baptized for a dead man could also be ordained on their behalf to the priesthood [REF].