Deuteronomy 30:2
And shalt return unto the LORD thy God, and shalt obey his voice according to all that I command thee this day, thou and thy children, with all thine heart, and with all thy soul; And shalt return unto the LORD thy God, and shalt obey his voice according to all that I command thee this day, thou and thy children, with all thine heart, and with all thy soul;
Moses places this call after both the blessing and the curse have come upon Israel, when they have been driven as captives among all the nations and call those experiences to mind. Returning to the Lord is repentance after judgment, turning to Him in penitence and faith with all the heart and with all the soul, together with their children, acknowledging His faithfulness and being loyal, true, and submissive. Obeying His voice means keeping His commandments wholeheartedly, and refusing to return in this way leaves a person resisting His message and grieving the Holy Spirit. If they so return, He answers with compassion, pardon, and renewed favor, gathering them even from the farthest places, taking them to Himself again, and establishing them in their own land.
The scattering came after Israel was established in Canaan with each tribe in its own possession, through a long history of apostasy and separation from God. They had failed to be His missionaries and had built walls of division between themselves and the people around them. Because of their sins the glory departed, the beautiful city lay in ruins, Jerusalem was destroyed by fire, and the people were overcome, carried into heathen lands, and held as captives in strange lands. Even that dispersion served His purpose to carry the knowledge of His truth to the world.
The promise was fulfilled to the letter in the restoration of repentant captives to the land of their fathers before they at last came under the dominion of Rome, while continual disobedience resulted in complete overthrow and the overthrow of Jerusalem. The promise remains sure through the centuries because His word does not fail. The command to return and obey was to be put into song and sung by all the Israel of God, lest matters of such great importance be forgotten.