At the end of his life, there was much that Moshe wanted the Israelites to understand.  To be clear, Moshe repeated truths over and over again from many different angles.  The most important fact was that YHWH is their Elohim.  He is faithful to those with whom He made covenant.  But Moshe also warned them that obedience was key for His blessings to flow over their lives.  
YHWH 's choice of, and His love for Israel was NOT conditional.  Nor was the covenant He made with Avraham, Yitzchak, and Ya'acov.  What was conditional, however, was the intensity of blessing that Israel would experience if they loved and obeyed YHWH with all their hearts.  Read these incredible blessings for obedience:
Devarim/Deuteronomy 7:12 " Then it shall come to pass, because you listen to these judgments, and keep and do them, that YHWH your Elohim will keep with you the covenant and the mercy which He swore to your fathers. 13 "And He will love you and bless you and multiply you; He will also bless the fruit of your womb and the fruit of your land, your grain and your new wine and your oil, the increase of your cattle and the offspring of your flock, in the land of which He swore to your fathers to give you. 14 "You shall be blessed above all peoples; there shall not be a male or female barren among you or among your livestock. 15 "And YHWH will take away from you all sickness, and will afflict you with none of the terrible diseases of Egypt which you have known, but will lay them on all those who hate you. 16 "And you shall destroy all the peoples whom YHWH your Elohim delivers over to you; your eye shall have no pity on them; nor shall you serve their gods, for that will be a snare to you.
But there is something that goes beyond mere obedience.  And this is so very important to YHWH .  That is, the condition of the heart.  The "why you do what you do."  YHWH doesn't just want robots.  He gave His people the ability to choose, and He wants us all to obey Him out of pure love.  To obey Him because we have become His followers and we have taken on His mission.  We want to be true disciples.  But first...the condition of the heart has to be worked on... 
To begin with, the Israelites had to be reminded that they had been chosen not because of any attributes of their own, but because YHWH first loved them and He is faithful:
Devarim/Deuteronomy 7:7 " YHWH did not set His love on you nor choose you because you were more in number than any other people, for you were the least of all peoples; 8 "but because YHWH loves you, and because He would keep the oath which He swore to your fathers, YHWH has brought you out with a mighty hand, and redeemed you from the house of bondage, from the hand of Pharaoh king of Egypt. 9 "Therefore know that YHWH your Elohim, He is Elohim, the faithful El who keeps covenant and mercy for a thousand generations with those who love Him and keep His commandments; 10 "and He repays those who hate Him to their face, to destroy them. He will not be slack with him who hates Him; He will repay him to his face.
For 40 years He had them in a place of testing.  The time in the wilderness was not just a punishment for their unbelief, but also a time for the nation to be trained and educated for their future destiny.  Everything He did was necessary to perfect the heart so His people would lovingly keep the commandments:
Devarim/Deuteronomy 8:2 "And you shall remember that YHWH your Elohim led you all the way these forty years in the wilderness, to humble you and test you, to know what was in your heart, whether you would keep His commandments or not.

The hardships in the wilderness were balanced by His miraculous provisions both of which were designed to test "what was in your heart, whether you would keep His commandments or not" (Devarim 8:2).  By their "hunger" as well as by the "manna" which He provided, they were to "know that man does not live by bread alone..."

Devarim/Deuteronomy 8:3 "So He humbled you, allowed you to hunger,and fed you with manna which you did not know nor did your fathers know, that He might make you know that man shall not live by bread alone; but man lives by every word that proceeds from the mouth of  YHWH.
The Almighty will literally take this fledgling nation which He has rescued out of bondage from Egypt and "discipline" them through educational corrections that will bring about a reformation of the heart.  YHWH compares His "discipline" to the same what a "man does with his son."  In fact to know that He is in the process of "discipline," is something important to "know in their hearts."  
Devarim/Deuteronomy 8:5 "You should know in your heart that as a man disciplines his son, so YHWH your Elohim disciplines you.
The Hebrew word verb for "discipline" is "yasar" and the noun for "discipline" is "musar."  "Discipline" is not always punishment.  But it is a chastisement that is intended to correct or train.  The intended end result of "discipline" was restoration.  The theological basis for "discipline" is grounded in the covenant relationship which YHWH established with His people.   Read how the writer of Hebrews speaks about the positive consequence of YHWH's "discipline":
Hebrews 12:5 And you have forgotten the exhortation which speaks to you as to sons: "My son, do not despise the discipline of YHWH, Nor be discouraged when you are rebuked by Him; 6 For whom YHWH loves He disciplines, And scourges every son whom He receives." 7 If you endure disciplining, Elohim deals with you as with sons; for what son is there whom a father does not discipline? 8 But if you are without disciplining, of which all have become partakers, then you are illegitimate and not sons. 9 Furthermore, we have had human fathers who corrected us, and we paid them respect. Shall we not much more readily be in subjection to the Father of spirits and live? 10 For they indeed for a few days disciplined us as seemed best to them, but He for our profit, that we may be partakers of His holiness. 11 Now no disciplining seems to be joyful for the present, but painful; nevertheless, afterward it yields the peaceable fruit of righteousness to those who have been trained by it.
YHWH Elohim has dealt with and will continue to deal with His people from the standpoint of warning and correction.  In fact, the exile can be understood as way of "disciplining" his children:
Jeremiah 35:13 "Thus says YHWH of hosts, Elohim of Israel: 'Go and tell the men of Judah and the inhabitants of Jerusalem, "Do you not receive discipline (musar) to obey My words?" says YHWH "I have also sent to you all My servants the prophets, rising up early and sending them, saying, 'Turn now everyone from his evil way, amend your doings, and do not go after other gods to serve them; then you will dwell in the land which I have given you and your fathers.' But you have not inclined your ear, nor obeyed Me. ... 17 "Therefore thus says YHWH Elohim of hosts, the Elohim of Israel: 'Behold, I will bring on Judah and on all the inhabitants of Jerusalem all the doom that I have pronounced against them; because I have spoken to them but they have not heard, and I have called to them but they have not answered.' "

How frustrating for our Father, when His children did not respond to His "discipline":

Jeremiah 32:33 'And they have turned to Me the back, and not the face; though I taught them, rising up early and teaching them, yet they have not listened to receive discipline (musar) .
Jeremiah 17:23 "But they did not obey nor incline their ear, but made their neck stiffthat they might not hear nor receive 
discipline (musar)
Jeremiah 7:28 Therefore say to them, 'This is the nation that has not obeyed  YHWH its Elohim or responded to discipline (musar). Truth has perished; it has vanished from their lips.
So what do we need to do now?  Since we are still in exile, the message is still the same:
Revelation 3:19 "As many as I love, I rebuke and discipline. Therefore be zealous and repent. 20 "Behold, I stand at the door and knock. If anyone hears My voice and opens the door, I will come in to him and dine with him, and he with Me.

If we find ourselves in the place of "discipline," we should keep in mind it is for our growth and good, that we may be warned of a dangerous course of life or action if we  continue on our own path.  His correction is perfect and will bring us closer to Him.  It will aid us in living a life aimed toward holiness.  In our repentance and remorse, He will restore us.

Proverbs 3:11 My son, do not despise the discipline (musar) of YHWH, Nor detest His correction; 12 For whom YHWH loves He corrects, Just as a father the son in whom he delights. 13 Happy is the man who finds wisdom, And the man who gains understanding; 14 For her proceeds are better than the profits of silver, And her gain than fine gold.
Psalm 94:12 Blessed is the man whom You discipline (yasar), O YHWH , And teach out of Your Torah
"Discipline" can feel like a terrible trial, yet catch the perspective of Ya'acov, brother of Yeshua.  He understood that the real point of "discipline,"  is to bring us to "completion":
James 1:2 My brethren, count it all joy when you fall into various trials, 3 knowing that the testing of your faith produces patience. 4 But let patience have its perfect work, that you may be perfect and complete, lacking nothing.
In closing, the Israelites were being trained in the wilderness to worship the one true Elohim in spirit with a pure heart.  This was a huge change for a people who had been taken out of Egypt where life revolved around a multitude of gods which were reverenced through a variety of physical symbols.  In the wilderness they were being taught to serve YHWH by faith.  Yet the testimony of who He was surrounded them.  There was the cloud and fire of His glory, the manna upon the ground, their feet did not grow weary, and their very clothes did not wear out.  The Father's testimony of love was always with them.  For us today, let's be aware (and thankful) of our Father's love for us.  It is still all around us, in the many good things He has provided for us.  Sure there are trials, but nothing to compare with His goodness.  
1 Thessalonians 5:18 in everything give thanks; for this is the will of Elohim in Messiah Yeshua for you.
1 John 4:19 We love Him because He first loved us.
What's the condition of your "heart"?  Loving Him and keeping His commandments go hand in hand:
Devarim/Deuteronomy 6:4 " Hear, O Israel: YHWH our Elohim, YHWH is one! 5 "You shall love YHWH your Elohim with all your heart, with all your soul, and with all your strength

John 14:15 " If you love Me, keep My commandments.
And that is exactly what will bring us out of exile:
Jeremiah 29:13 And you will seek Me and find Me, when you search for Me with all your heart. 14 I will be found by you, says YHWH, and I will bring you back from your captivity; I will gather you from all the nations and from all the places where I have driven you, says YHWH, and I will bring you to the place from which I cause you to be carried away captive.

Shabbat Shalom!