Joseph Smith said,
That which is wrong under one circumstance, may be, and often is, right under another. God said, “Thou shalt not kill;” at another time He said, “Thou shalt utterly destroy.” This is the principle on which the government of heaven is conducted–by revelation adapted to the circumstances in which the children of the kingdom are placed. Whatever God requires is right, no matter what it is, although we may not see the reason thereof till long after the events transpire….
Teachings of the Prophet Joseph Smith, p. 256