Another interpretation of "When you come into the land" (Leviticus 19:23). This is what Scripture says: "And He gave them the lands of the nations... so that they might keep His statutes" (Psalms 105:44-45). "And He gave them the lands of the nations" - everything that the Holy One, blessed be He, took from the nations of the world He gave to Israel: lands of silver and gold, fields and vineyards and cities. And He gave these to them only so that they might occupy themselves with the Torah, as it is said, "so that they might keep His statutes" (ibid.). But they did not do so. Instead, "they defiled it by their way and by their deeds" (Ezekiel 36:17). They defiled them through the proscribed spoil of Achan, as it is said, "And you came and defiled My land" (Jeremiah 2:7) - through the proscribed spoil of Achan; "and you made My inheritance an abomination" (ibid.) - through the image of Micah. And what did the Holy One, blessed be He, do to them? He exiled them from within it, as it is said, "And the Lord uprooted them from their land" (Deuteronomy 29:27). What is "and He uprooted them"? He weakened their strength. They would sow and toil, and the nations of the world would come and take, as it is said, "And it would be, if Israel sowed..." (Judges 6:3), and it is written, "And they would encamp against them and destroy the produce of the land" (ibid. 6:4). But when they do repentance, "they shall not build and another dwell, they shall not plant and another eat" (cf. Isaiah 65:22), because they shall plant and not be uprooted, as it is said, "And they shall no more be uprooted from their land which I have given them, says the Lord your God" (Amos 9:15).
Why God Gave Israel the Land and Then Uprooted Them
Midrash Tanchuma Buber, Kedoshim 11:1
ד"א כי תבאו אל הארץ. זש"ה ויתן להם ארצות גוים וגו' בעבור ישמרו חקיו וגו' (תהלים קה מד מה), ויתן להם ארצות גוים, כל מה שנטל הקב"ה מאומות העולם נתן לישראל, ארצות כסף וזהב שדות וכרמים וערים, ולא נתן להם, אלא כדי שיתעסקו בתורה, שנאמר בעבור ישמרו חקיו וגו' (שם), והם לא עשו כן, אלא ויטמאו (אותם כדרכם) [אותה בדרכם ובעלילותם] (יחזקאל לו יז), טמאו אותם בחרמו של עכן שנאמר ותבואו ותטמאו את ארצי (ירמיה ב ז), [בחרם עכן], ונחלתי שמתם לתועבה (שם) בצלמו של מיכה, ומה עשה להם הקב"ה, הגלה אותם מתוכה, שנאמר ויתשם ה' מעל אדמתם (דברים כט כז), מהו ויתשם, התיש חילם, היו זורעים ויגיעים, ואומות העולם באין ונוטלין, שנאמר והיה אם זרע ישראל וגו' (שופטים ו ג), וכתיב ויחנו עליהם וישחיתו את יבול הארץ (שם שם ד), וכשעושים תשובה לא יבנו ואחר ישב, לא יטעו ואחר יאכל למה שהן נוטעין ואינן נותשין, שנאמר ולא ינשתו עוד מעל אדמתם אשר נתתי להם אמר ה' אלהיך (עמוס ט טו).