I am the law and the light. Look unto me, and endure to the end, and ye shall live; for unto him that endureth to the end will I give eternal life… This is the law and the prophets, for they truly testified of me. 
What we call the Old Testament Jesus referred to as “the law and the prophets.” The Lord intends everything in the Old Testament to bring us to Christ. As our goal in life is to “come unto Christ and be perfected in him,”  the Old Testament becomes a precious and invaluable guidebook.
The question posed by this lesson is: How does the story of King David’s wrongdoing and repentance help us come unto Christ?
“Wherefore hast thou despised the commandment of the Lord?”
The story of David and Bathsheba is one of the most profound tragedies in scripture. Blessed with kingdoms and thrones, with miraculous deliverance from the monstrous Goliath and from the deviousness of King Saul, David was beloved by the Lord — indeed his very name means “beloved.” The Lord was eager to bless David for his faithfulness, gifting him with wives and children and even promising that through him the Messiah would come to Earth.
But David broke the most sacred of covenants by committing adultery with Bathsheba, another man’s wife, and compounded this sin by arranging for the death of her husband Uriah in order to conceal his sin from the world. 
David is truly a tragic figure. In ancient times, the word “tragedy” was reserved to describe the fate of those who bring about their downfall through their own moral miscalculation. Today, we throw the word “tragedy” around too much. We use the word to refer to accidents, untimely deaths, or painful misfortunes. Often, these events are not tragic in themselves, and can in some circumstances even be blessings. But the figure who is really tragic is the one who surrenders to the fatal flaws within his own heart and must reap the inevitable consequences.
The Lord revealed to the Prophet Joseph Smith in Doctrine and Covenants 132 the serious consequences of David’s offense. We learn that David’s wives were given him in marriage by the hand of the Lord’s authorized servants, Nathan and other prophets, “and in none of these things did he sin against me save in the case of Uriah and his wife; and therefore he hath fallen from his exaltation, and received his portion; and he shall not inherit them out of the world, for I gave them unto another, saith the Lord.” 
Section 132 also contrasts David’s fall from exaltation with the ascent to exaltation of his faithful ancestors: Abraham “abode in my law; as Isaac also and Jacob did none other things than that which they were commanded; and because they did none other things than that which they were commanded, they have entered into their exaltation, according to the promises, and sit upon thrones, and are not angels but are gods.” 
God promised to David the same blessings promised to his fathers: “Exaltation and glory in all things… which glory shall be a fulness and a continuation of the seeds forever and ever. Then shall they be gods, because they have no end.” 
Through his sinfulness, David turned his back on an eternal kingdom for which his earthly kingdom was only a type and shadow. He turned his back on an everlasting posterity of which his earthly family was only a beginning. The great tragedy of David, and the great irony of his life, was that the Lord would have blessed him without limits if only he had remained within the limits the Lord set out for him. Through the prophet Nathan, the Lord lamented over the blessings David had forfeited:
I anointed thee king over Israel, and I delivered thee out of the hand of Saul; and I gave thee thy master’s house, and thy master’s wives into thy bosom, and gave the house of Israel and of Judah; and if that had been too little, I would moreover have given unto thee such and such things. Wherefore hast thou despised the commandment of the Lord, to do evil in his sight? 
A portentous question, and one that requires careful heart-searching by everyone who hopes for the blessings of exaltation.
“Take not thy holy spirit from me”
In Psalm 51, David squarely faces the tragic flaw in himself: he has an unclean heart. Instead of strictly obeying Samuel’s commandment to “serve the Lord with all your heart,”  David reserved space in his heart for forbidden thoughts and desires, and as a result the Spirit of the Lord withdrew from him.
By acting on those thoughts and desires, by first looking on Bathsheba and then inviting her into his rooms, he quickly entangled himself in the deadly sin of unchastity, which is “most abominable above all sins save it be the shedding of innocent blood or denying the Holy Ghost.”  Tragically, he went on to create the circumstances wherein the innocent blood of Uriah would be shed.
The lesson for us could not be more stark. We need the Spirit of the Lord with us always, and we need to turn immediately from those things that would repel the Spirit. As Elder David A. Bednar has said:
The standard is clear. If something we think, see, hear, or do distances us from the Holy Ghost, then we should stop thinking, seeing, hearing, or doing that thing… Because the Spirit cannot abide that which is vulgar, crude, or immodest, then clearly such things are not for us… We should remember that the covenant promise is that we may always have His Spirit to be with us. This supernal blessing applies to every single member of the Church who has been baptized, confirmed, and instructed to ‘receive the Holy Ghost.’” 
King David fully realizes that he has forfeited the presence of the Spirit in his life. “Take not thy holy spirit from me,” he pleads. 
We are all subject to the weaknesses of mortality. All who try find it challenging to give their full hearts to God. He understands this, and for this reason He has invited us to “repent, and call upon God in the name of the Son forevermore”  so we may progressively give more and more of our hearts to God.
Sometimes we bow down under the burden of our own frailties and feel hopeless. Sometimes we find ourselves so remote from the Spirit of the Lord we suppose we can never get back. Sometimes we are tempted to give up.
To every bruised, despairing, distraught soul — for everyone who feels overwhelmed by his or her own flaws and frailties — the Lord has made a promise: if we will only repent and not give up on ourselves, if we will exercise faith in Him, He will do a miracle. He will “create in us a clean heart,” which is the key condition for entrance into His kingdom, and ultimately erase those flaws that threaten our peace.
“Create in me a clean heart, O God”
The Psalmist prays, “Create in me a clean heart, O God; and renew a right spirit within me.”  God knows that we are not capable of coming unto Him on our own, but He is capable of cleansing our hearts.
The word “create” in this verse is the Hebrew word bara, which is used in the Old Testament only to refer to acts of God Himself. We cannot create this cleanliness in ourselves: only He can do this. The word “clean” in this verse is the Hebrew word tahor, which is used in the Old Testament to refer to things that are pure, unmixed, and unsullied with anything else. The Temple furnishings, for example, were of pure (tahor) gold to typify the purity of His kingdom and the fact that only the pure in heart can enter that kingdom. 
Now, the good news of the Gospel is that we can all have pure hearts. Purity of heart is the greatest gift of the Atoner. The miracle of a purified heart is an act of God, which He will create within every soul who truly repents. “For, behold, the Lord your Redeemer suffered death in the flesh; wherefore he suffered the pain of all men, that all men might repent and come unto him.” 
So when confronted with the impurity of our own hearts, we should pray as the people of King Benjamin did: “O have mercy, and apply the atoning blood of Christ that we may receive forgiveness of our sins, and our hearts may be purified; for we believe in Jesus Christ, the Son of God.” 
It is true that the cleansing blood of the Savior purifies hearts; but the blessing applies only to those who qualify themselves through repentance. Such purifying repentance requires absolute honesty with the self: “Behold, thou desirest truth in the inward parts: and in the hidden part thou shalt make me to know wisdom.” 
The repentant soul must acknowledge sin without reservation: “For I acknowledge my transgressions: and my sin is ever before me.
”  It isn’t enough to simply go through the motions of repentance — to casually ask forgiveness for “weaknesses” or take the sacrament without real intent. Too many of us approach the sacrament table without serious inward-looking examination. “But let a man examine himself, and so let him eat of that bread, and drink of that cup.” 
“A broken and a contrite heart”
Furthermore, purifying repentance requires a certain type of sacrifice: “The sacrifices of God are a broken spirit: a broken and a contrite heart.” 
The Hebrew word translated “broken,” shabar, means literally shattered in pieces. The Hebrew word translated “contrite,” daka, means literally bruised. Purification requires the sacrifice of a heart broken and bruised for sin. The heart of the Atoner Himself was broken and bruised, not for His own sins, but for our sins.  “Behold, he offereth himself a sacrifice for sin, to answer the ends of the law, unto all those who have a broken heart and a contrite spirit; and unto none else can the ends of the law be answered.” 
A hard heart cannot be broken and bruised — only a tender heart — and only a tender heart that is humble and contrite is fit for the kingdom of God. Even God cannot “take a thing of a natural state and place it in an unnatural state.” 
But if we will acknowledge our sins with absolute honesty and bring the appropriate sacrifice to the sacrament table, the Lord will cleanse us. “Ye shall offer for a sacrifice unto me a broken heart and a contrite spirit. And whoso cometh unto me with a broken heart and a contrite spirit, him will I baptize with fire and with the Holy Ghost.” 
It is the fire of the Holy Ghost that purifies. In the ancient Temple, the sacrificial fire upon the altar betokened the purification of the hearts of Israel. Now, as then, we are called upon to bring our hearts to the sacrament table, to be purified with fire by the hand of the Lord Jesus Christ. “Thou shalt offer a sacrifice unto the Lord thy God in righteousness, even that of a broken heart and a contrite spirit. And… thou shalt go to the house of prayer and offer up thy sacraments upon my holy day.” 
May we come unto Christ each week at the sacrament table, honestly acknowledging our sins and offering up the sacrifice of a humbled heart, so that He may create in each of us a clean heart.
 3 Ne. 15:9-10.
 Moro. 10:32.
 2 Sam. 11, 12.
 D&C 132: 39.
>  D&C 132: 37.
<  D&C 132: 19-20.
 2 Samuel 12: 7-9.
 1 Sam. 12:20.
 Alma 39:5.
 “That We May Always Have His Spirit to Be with Us,” Ensign, May 2006, p. 30.
 Psalms 51:11.
 Moses 5:8.
 Psalms 51:10.
 Exodus 25:11-39; Psalms 24:4.
 D&C 18:11.
 Mosiah 4:2.
 Psalms 51:6.
 Psalms 51:3.
 1 Cor. 11:28.
 Psalms 51:17.
 Isaiah 53:5.
 2 Ne. 2:7.
 Alma 41:12.
 3 Ne. 9:20.
 D&C 59:8-9.