Three Commandments on Entering the Land

Yalkut Shimoni on Torah 268:1

It was taught: Rabbi Judah says: Israel was commanded with three commandments upon entering the land - to appoint over them a king, to cut off the seed of Amalek, and to build for them the Chosen House [the Temple]. And I do not know which comes first. When Scripture says, "For there is a hand upon the throne of the LORD, war for the LORD against Amalek" (Exodus 17:16), this tells you that appointing a king comes first, and "throne" refers only to a king, as it is said (1 Chronicles 29:23), "And Solomon sat upon the throne of the LORD." And still I do not know whether to cut off the seed of Amalek comes first or to build the Chosen House comes first. When Scripture says, "And He will give you rest from all your enemies around, so that you dwell in security, and the place which the LORD your God will choose to cause His name to dwell there" (Deuteronomy 12:10-11), you learn from this that cutting off the seed of Amalek comes first. And so it says of David (2 Samuel 7:1-2), "And it came to pass when the king [David] dwelt in his house, and the LORD had given him rest round about... that the king said to Nathan the prophet: See now, I dwell in a house of cedar, but the ark of God dwells within a curtain."

Themes