Outcomes and the actions that lead to them are laws. These are the rules of reality. They were established before the foundation of the world:
20 There is a law, irrevocably decreed in heaven before the foundations of this world, upon which all blessings are predicated—
21 And when we obtain any blessing from God, it is by obedience to that law upon which it is predicated. (D&C 130)
Reality is just like a chess game: the rules are established before the game begins. The objective of the player is to navigate those rules to obtain the outcome they seek. They have to learn the rules, make a plan, act to win, and adjust based on new information.