Deuteronomy 31:20-22

MLV(i) 20 For when I will have brought them into the land which I swore to their fathers, flowing with milk and honey and they will have eaten and filled themselves and grown fat, then they will turn to other gods and serve them and despise me and break my covenant.
21 And it will happen, when many evils and troubles have come upon them, that this song will testify before them as a witness, for it will not be forgotten out of the mouths of their seed. For I know their imagination which they frame this day, before I have brought them into the land which I swore.
22 So Moses wrote this song the same day and taught it to the sons of Israel.