God had at first left the war against Amalek in the hands of His people, therefore He bade Joshua, the future leader of the people, never to forget the war against Amalek; and if Moses had listened intently, he would have perceived from this command of God that Joshua was destined to lead the people into the promised land. But later, when Amalek took part in the destruction of Jerusalem, God Himself took up the war against Amalek, saying, "By My throne I vow not to leave a single descendant of Amalek under the heavens, yea, no one shall even be able to say that this sheep or that wether belonged to an Amalekite."
Why God Commanded Israel Never to Forget Amalek
Legends of the Jews 1:129