The above is one of the quintessential scriptures for Mormons on the meaning of this life. Another is:
"[A]fter this day of life, which is given us to prepare for eternity, behold, if we do not improve our time while in this life, then cometh the night of darkness wherein there can be no labor performed." (Alma 34:33).
Particularly poignant is that "For, behold, the mystery of godliness, how great is it! For, behold, I am endless, and the punishment which is given from my hand is endless punishment, for Endless is my name. Wherefore—Eternal punishment is God’s punishment. Endless punishment is God’s punishment." (D&C 19:10-12). In some kind of trick-wording, God is saying that punishment is to last forever in the way God (by his name) lasts forever.
To Mormons, this life--from birth to resurrection & judgment--is primarily about proving our faith through obedience, and secondarily about learning/growing closer to God to become like him. The reason most people fail (i.e., aren't mormons) is because they choose evil over righteousness. And when they commit a finite crime of choosing momentary evil, they just might receive endless punishment, if it weren't for God's stepping in. Does eternal punishment for a finite 'crime' make sense? This is an elaborate scheme for when we purposely choose evil.
But do we? Does anyone actually willingly choose what they believe is outright evil? Most of you have seen studies indicating that brain damage can coincide with onset of violent behavior, in what was a normal, passive, loving person prior to the damage. Is biology the only source of violence?
LDS teachings hold that we have a thing called agency which allows each of us to choose between right and wrong. LDS doctrine on agency is fundamental to everything. Without agency & choice, the entire plan of God would be frustrated (2 Nephi 2:11-13). In fact, without the opposition that allows choice through agency, God would even cease to be God (2 Ne 2:13 & Alma 42:22-25). (It's not explained how God was God before there existed Satan.)
However, as is discussed (sometimes argued) in other sects of Christianity, while we are free to act, are we really free in our choice? Do you have free will?
At this point you probably "phht!" me and sigh in frustration. How could anyone question whether we are free to choose? We feel it deeply, deeper than our bones; that we are authoring most of our life.
But I didn't say free to choose. I said free in our choice. I am not talking about freedom of choice. There is a subtle difference that I think many people don't make.
A robot can be programmed to choose when it reaches a fork in its path. Its choice is conditional and the parameters are based on its programming. The robot makes a choice. Unless a subroutine blocks other code, we can say it is free to make a choice when it comes to a fork. It doesn't create the fork. It doesn't even create its own internal conditions ("desires" that push it one direction over another). If its programming blocks that choice under certain circumstances or if its programming does not have the conditions or information needed to make a choice, it will hover and pace at the fork not knowing what to do until conditions change or it flips a virtual coin (assuming its programming includes the option of random choice whenever no other conditions are met).
Where did the robot obtain the ability to choose? Duh! From its programmers!
Where did humans get the ability to choose? We have will--the freedom of choice. But can we will our will? Can we create the desires, conditions and programming behind our choices? Where do those come from, if not the brain, genetics and environment? Mormon teaching by some prophets explain the fundamental will to choose--agency--is a co-eternal property of children of God, something we have in common with him and always will have.
But is this agency different than a robot's programming to choose? Free will is more than the ability to choose (that's called "freedom" here). Free will is the independent source of choice, free of external (divine or other) influencers. Without that independence, could there be a true test of God's children?
Think about it this way, if you could rewind the universe and re-watch it play, would an intelligent person choose differently, given everything material (brain, environment, etc) is equivalent? If so, what is it that would be choosing differently since it wouldn't be the brain or different conditions? Remember, you didn't choose the structure of your brain at birth, the genetics you received or the environment you were born into.
Many will argue that the difference between a robot with programming to choose and us is our consciousness. We feel we make choices. The robot is not conscious. True. If we are just moist robots, our programming sure makes us feel special anyway. Could we be confusing warm fuzzy special feelings with something more magical?
What is consciousness? Does it make the choice? In fact, there are data showing strong evidence that conscious choice is an illusion [1-3 footnotes]. That choice happens, according to readings from EEG & fMRI sensors, 100s of miliseconds to seconds before we are conscious of it. Is our conscious self the one deciding? Not according to latest evidence.
Mormons believe that there is a part of us that is pre-ordinate to our genes and birth/earth environment. They call this "intelligences", and this is the agent that has free will (even eternal and separate from God). But one has to wonder how the intelligence agent chooses when everything else that influences choice--genetics, environment, the intelligence (or lack thereof) of others around us, God, Satan--all the other factors beyond our control cannot truly choose. We cannot change our genetics, we cannot change God or Satan or really even forcibly alter the mind of others (not without really good pharmaceutics or waterboarding). Nor did we choose the environment in which we were born. And every decision you've made from that moment is dependent on the environmentally evolving brain, step-by-step ad-naseum until you are what you are, where you are, and how you are today. What in all of that did you really choose that is independent of all those steps over which you truly had no control?
"Our intelligence/soul," you may answer. An agent such as a soul or the Mormon intelligence that is proposed to act will by necessity follow rules (or be undetermined & random). Where did those rules (programming) come from? Did you choose to be a particular flavor of intelligence? No. If it exists, it is still something that either is what it is or it was organized by God into a soul for you. Every other factor that made the conditions of what you are is outside of your control. And neither are you in control of the very core of yourself that might be "co-eternal".
But the choices you make are based on this (hypothetical) core soul, the genetics, your birth environment and the subsequent infinitely complex evolving interaction of your genetics/brain with the changing environment.
God said, in LDS scripture, "Every spirit of man was innocent in the beginning." (D&C 93:38).
So if you in fact also started with a clean slate, then there were no differences between each of us before we arrived on mother earth. If that is true doctrine, then what is the test? To see if we will execute the wetware inside our moist robotic brains? What is God really judging us for? Our most base/core level programming (intelligences) is not our doing. The organization of our spirit bodies was God's act. Our genetics were just dumped on us. We were born whereever we were born and we get whatever family we get.
The only real test seems to be: did God organize the intelligences into spirits and match them with the right genetics and environment? The test is on God, not us. That is, if you believe in LDS scripture and place a little thought into it.
This life is a test. How would you grade God so far?
 I. Fried, R. Mukamel, & G. Kreiman, 2011. Internally generated preactivation of single neurons in human medial frontal cortex predicts volition. Neuron, 69: 548– 562 http://www.ncbi.nlm.nih.gov/pubmed/21315264
 J. D. Haynes, 2011. Decoding and predicting intentions. Ann. NY Acad. Sci. 1224(1): 9–21. http://www.ncbi.nlm.nih.gov/pubmed/21486293