According to LDS teachings, the law of agency was predetermined prior to this life. Those who opposed the law (Lucifer and his followers) were cast out of heaven. The Plan(LDS) of Heavenly Father was that men would have choices to make; Christ sustained the the Plan. Lucifer opposed the Plan (he was already rebellious).
Wherefore, because that Satan rebelled against me, and sought to destroy the agency of man, which I, the Lord God, had given him, and also, that I should give unto him mine own power; by the power of mine Only Begotten, I caused that he should be cast down;
Moses 4:3
The scriptures teach us that the prophets prepared themselves to become leaders on earth while they were still spirits in heaven (see Alma 13:1–3).
LDS.org - Family Chapter Detail - Our Heavenly Family
We believe that everything is ruled by law. We are thankful that it is so, for otherwise we would live in a world of chance, in a fearful uncertainty of what would happen next. I believe that the material laws that can be traced in the creation had an intelligent will behind them, that the laws themselves were never superior to the will of God. He made those laws, and by His power they became effective to accomplish His purposes.
Anthon H. Lund, Conference Report, April 1916, p. 12
Who is it that is at the head of this? It is the Devil, the mighty Lucifer, the great prince of the angels, and the brother of Jesus. He left the province of his Father, and took with him a third part of his Father's kingdom, and there was no other alternative but to banish him. God would have saved him if he could; but he could not.
Joseph Young, LDS Apostle, Journal of Discourses, vol. 6, p. 207-208, October 11, 1857
"All kingdoms have a law given; and there are many kingdoms; for there is no space in which there is no kingdom; and there is no kingdom in which there is no space, either a greater or a lesser kingdom. And unto every kingdom is given a law; and unto every law there are certain bounds also and conditions."
D&C 88:36-38
All of that is LDS teaching. Those who make the correct choices get blessed, those who make incorrect choices don't.