What are these things so? I like to ask questions of purpose. The answers can be very helpful. A collection of several details and facts is nice but it is better to have a narrative that brings them all together in proper order and context. But answers are not always given. When Moses asked why all "these things" were so he was first told "For mine own purpose have I made these things. Here is wisdom and it remaineth in me." (Moses 1:31) Moses was given great knowledge and exposure to the work of God but he was not shown everything. In fact he could not behold all of God's works "and afterwards remain in the flesh on the earth." (Moses 1:5) But much was revealed to him and, through Joseph Smith, to us. Referring to all His works throughout the universe the Lord God said: "For behold, this is my work and my glory—to bring to pass the immortality and eternal life of man." (Moses 1:39) This is context for the great vision. The worlds, the plan were framed to bring to pass our immortality and eternal life.
This context gives us some understanding of the details in our lives. It is not exhaustive, but it helps.
Why are we born?
Why do we die?
Why do we have fun?
Why do we feel pain?
There are not always specific answers given to understand the divine purpose of each individual experience but there is a general context. "All these things shall give thee experience, and shall be for thy good." (Doctrine and Covenants 122:7) These things have purpose. Everything works toward the work and glory of God: the immortality and eternal life of his children. Brigham Young gave this inspired teaching:
"All intelligent beings who are crowned with crowns of glory, immortality, and eternal lives must pass through every ordeal appointed for intelligent beings to pass through, to gain their glory and exaltation." (Journal of Discourses 8:150)
It is in this context of God's purposes that we can understand His laws. In fact it can help to understand the nuanced teachings of Jesus in what some have called the "spirit of the law". Laws themselves, being part of the great plan, are not without purpose. God's laws have meaning and purpose. The "spirit of the law", its purpose and meaning can be better understood by knowing who God is and who we are. Joseph Smith taught:
"If men do not comprehend the character of God, they do not comprehend themselves." (History of the Church 6:303)
The revelations given to Joseph Smith teach that God is a person with a "body of flesh and bones" (Doctrine and Covenants 130:22). Joseph Smith even taught: "God himself was once as we are now, and is an exalted man." (History of the Church 6: 305). Unmistakably, this is a doctrine of a personal God in the most literal sense. We also know that God has passions, or to use a more common term, feelings. God has very intense love and attachment to his children. The Johannine author even taught that "God is love". (1 John 4:8) What is the relationship between this personal God and us, His children? Why do we need to understand the character of God to comprehend ourselves?
"God himself, finding he was in the midst of spirits and glory, because he was more intelligent, saw proper to institute laws whereby the rest could have a privilege to advance like himself. The relationship we have with God places us in a situation to advance in knowledge. He has power to institute laws to instruct the weaker intelligences, that they may be exalted with Himself, so that they might have one glory upon another, and all that knowledge, power, glory, and intelligence, which is requisite in order to save them in the world of spirits." (History of the Church 6:312)
This is a most fascinating account of the origin of divine law. Not only does this narrative reveal the origin of law but also its purpose. Laws our given so that, by obeying them, we can advance and be exalted, becoming like God. It is an invigorating doctrine. Joseph Smith remarked immediately after teaching this:
"This is good doctrine. It tastes good. I can taste the principles of eternal life, and so can you. They are given to me by the revelations of Jesus Christ; and I know that when I tell you these words of eternal life as they are given to me, you taste them, and I know that you believe them. You say honey is sweet, and so do I. I can also taste the spirit of eternal life. I know that it is good; and when I tell you of these things which were given me by inspiration of the Holy Spirit, you are bound to receive them as sweet, and rejoice more and more." (History of the Church 6:312)
Understanding both the origin and purpose of the laws of God can help us to comprehend the "spirit of the laws" as taught by Jesus. Consider Jesus' somewhat midrashic exposition of the commandment against murder:
"Ye have heard that it was said by them of old time, Thou shalt not kill; and whosoever shall kill shall be in danger of the judgment:"
"But I say unto you, That whosoever is angry with his brother without a cause shall be in danger of the judgment: and whosoever shall say to his brother, Raca, shall be in danger of the council: but whosoever shall say, Thou fool, shall be in danger of hell fire."
"Therefore if thou bring thy gift to the altar, and there rememberest that thy brother hath ought against thee; Leave there thy gift before the altar, and go thy way; first be reconciled to thy brother, and then come and offer thy gift."
"Agree with thine adversary quickly, whiles thou art in the way with him; lest at any time the adversary deliver thee to the judge, and the judge deliver thee to the officer, and thou be cast into prison. Verily I say unto thee, Thou shalt by no means come out thence, till thou hast paid the uttermost farthing." (Matthew 5:21-26)
Jesus taught that we must not only abstain from the act of murder but also from the thoughts and attitudes of anger. His counsel was to make peace with any who would be an adversary. This was not only a matter of righteous actions but righteous intent and desire. This teaching went further still:
"Ye have heard that it hath been said, Thou shalt love thy neighbour, and hate thine enemy."
"But I say unto you, Love your enemies, bless them that curse you, do good to them that hate you, and pray for them which despitefully use you, and persecute you; That ye may be the children of your Father which is in heaven: for he maketh his sun to rise on the evil and on the good, and sendeth rain on the just and on the unjust."
"For if ye love them which love you, what reward have ye? do not even the publicans the same? And if ye salute your brethren only, what do ye more than others? do not even the publicans so?"
"Be ye therefore perfect, even as your Father which is in heaven is perfect." (Matthew
What is the unifying principle of all the law? Asked another way, which is the great commandment in the law? Jesus said:
"Thou shalt love the Lord thy God with all thy heart, and with all thy soul, and with all thy mind. This is the first and great commandment."
"And the second is like unto it, Thou shalt love thy neighbour as thyself."
"On these two commandments hang all the law and the prophets." (Matthew 22:36-40)
The unifying principle is love. This is consistent with the teachings of Joseph Smith and other scriptures. "God is love" (1 John 4:8) and the laws were instituted so that we could advance like God. What is this state of advanced perfection that God enjoys? It is His perfect love. The laws of God, as understood through the teachings of Jesus and the revelations of Joseph Smith, reveal that laws are not only about actions that we perform but our very character, what we become.
This fundamental basis for divine law can give proper context to individual commandments. Describing the scriptural and theological foundation of moral obligation Latter-day Saint philosopher Blake Ostler wrote:
"What laws define the conditions of mutual self-realization that we must abide to partake of the divine nature? The answer is that there is one eternal law that defines this possibility: the law of love."
"...by learning to love one another, we learn to be as God is. The purpose of life is to learn--and to learn one thing in particular: to love one another. As we progress in knowledge, as we learn to love, we reflect the image and likeness of divinity in our countenances. The purpose of the moral law is to challenge us to so act that we love others as we love ourselves. Thus, good and evil can be defined solely in terms of the low of love."
"...Paradoxically, there is only one way to realize our nature--only one path to actualize our potential to be as God is; and that is to be as God is. How is it possible that to realize our potential to be as God we must be already as God is? By being loving, for that is how God is. Thus, the love command is the clearest expression that God's purpose for us is deification, to give us commandments to guide us to be what He is. The fact that love is commanded is also a clear recognition that our true nature is divine and that deification is the fullest realization of human potential."
"...God gives us all of the commandments to teach us how to love one another, for all commandments are summed up in the great command to love God with all of our heart, might, mind and strength and to love our neighbor as we love ourselves. God's purpose in giving us the commandments is also to lead us to exalted happiness and joy unalloyed." 
Understanding the origin and purpose of law in the context of Joseph Smith's King Follett Discourse also gives special insight into the role of doing and becoming in the Plan of Salvation. Law is not just about doing something, but also about becoming something. God instituted laws whereby we might advance like him and that is to become like him. This is idea is shown in a parable given by Elder Dallin H. Oaks:
"A wealthy father knew that if he were to bestow his wealth upon a child who had not yet developed the needed wisdom and stature, the inheritance would probably be wasted. The father said to his child:"
“'All that I have I desire to give you—not only my wealth, but also my position and standing among men. That which I have I can easily give you, but that which I am you must obtain for yourself. You will qualify for your inheritance by learning what I have learned and by living as I have lived. I will give you the laws and principles by which I have acquired my wisdom and stature. Follow my example, mastering as I have mastered, and you will become as I am, and all that I have will be yours.'"
"This parable parallels the pattern of heaven. The gospel of Jesus Christ promises the incomparable inheritance of eternal life, the fullness of the Father, and reveals the laws and principles by which it can be obtained." 
Of key importance here is that the significant outcome is character, not just a record of actions. Elder Oaks taught that the gospel of Jesus Christ challenges us to become something:
"Many Bible and modern scriptures speak of a final judgment at which all persons will be rewarded according to their deeds or works or the desires of their hearts. But other scriptures enlarge upon this by referring to our being judged by the condition we have achieved."
"The prophet Nephi describes the Final Judgment in terms of what we have become: 'And if their works have been filthiness they must needs be filthy; and if they be filthy it must needs be that they cannot dwell in the kingdom of God' (1 Ne. 15:33). Moroni declares, 'He that is filthy shall be filthy still; and he that is righteous shall be righteous still' (Morm. 9:14; see also Rev. 22:11–12; 2 Ne. 9:16; D&C 88:35). The same would be true of 'selfish' or 'disobedient' or any other personal attribute inconsistent with the requirements of God. Referring to the 'state' of the wicked in the Final Judgment, Alma explains that if we are condemned by our words, our works, and our thoughts, 'we shall not be found spotless; … and in this awful state we shall not dare to look up to our God' (Alma 12:14)."
"From such teachings we conclude that the Final Judgment is not just an evaluation of a sum total of good and evil acts—what we have done. It is an acknowledgment of the final effect of our acts and thoughts—what we have become. It is not enough for anyone just to go through the motions. The commandments, ordinances, and covenants of the gospel are not a list of deposits required to be made in some heavenly account. The gospel of Jesus Christ is a plan that shows us how to become what our Heavenly Father desires us to become." 
This state is to be like God, to advance like Him. God is not jealous of the kind of existence he enjoys. The very purpose of our life is to become like Him. That is why he has given us laws, commandments. And the essence of these laws is love.
1. Ostler, Blake. Exploring Mormon Thought: The Problems of Theism and the Love of God. p. 110-113.
2. Oaks, Dallin H. The Challenge to Become. Ensign. Nov. 2000.