Deuteronomy 31:21-22

21 And it shall come to pass, when many evils and troubles are befallen them, that this song shall testify against[a] them as a witness; for it shall not be forgotten out of the mouths of their seed: for I know their imagination which they go about, even now, before I have brought them into the land which I sware.
22 Moses therefore wrote this song the same day, and taught it the children of Israel.

Deuteronomy 31:21-22 Meaning and Commentary

INTRODUCTION TO DEUTERONOMY 31

Moses being old, and knowing he should quickly die, and must not go over Jordan with the people of Israel, acquaints them with it, and encourages them and Joshua to go over notwithstanding, and not be afraid of their enemies, since the Lord would go with them, and deliver them into their hands, De 31:1-8; and having written the law, he delivered it to the priests, and ordered that it should be read at the end of every seven years before all the people, that they and theirs might learn it, and fear the Lord, De 31:9-13; and whereas the death of Moses was very near, and the Lord foreseeing the people would quickly fall into idolatry, which would bring great calamities upon them, he directed Moses to write a song, which should be a witness for him, and against them, in ages to come; which Moses accordingly did, De 31:14-22; and Moses having given a charge to Joshua, and finished the writing of the law in a book, gave it to the Levites to put it in the side of the ark, De 31:23-27; and then ordered the chief of the tribes to be gathered together, that he might deliver the song, which by the direction and under the inspiration of God he had written, De 31:28-30; which song is recorded in De 32:1-43.

Footnotes 1

The King James Version is in the public domain.