What is the meaning of "va'Yetzei Gevul Bnei Dan Mehem"?
Rashi: They took some here, and also the lottery gave to them elsewhere, far from their inheritance, and other Shevatim interrupt in between. 1
Radak: What they received was too small for them. Part of what the lottery gave to them (Leshem) was not yet conquered; they conquered it later, in the days of Pesel Michah (Shoftim 18:1, 2, 27, 28). Refer to 19:47:3:1,2.
Abarvenel, Chomas Anach: What the lottery gave to them was too small for them.
Malbim: They did not dispossess the Emori, because their inheritance was not amidst Bnei Yisrael, rather, on the western border. Later they took Leshem, in the east.
Malbim (Shoftim 18:1): They did not dispossess the Kena'ani, and the Kena'ani took it back from them.
What is Leshem?
Radak, citing Bechoros 55a: It is Pamyas, the source of the Yarden. 'Yarden' hints to Yored (descends) mi'Dan.
Rashi (Shoftim 18:27): Here it is called Leshem, for they found there the gem called Leshem; this was the stone on the Choshen on which Dan's name was written. Through finding [this stone], they knew that it is their inheritance. Radak (ibid. and here) - the city had two names. It was far from the Dan's portion, outside of Eretz Yisrael. Bi'ur ha'Gra - Yehudah and Dan were both called Gur Aryeh, because they were at two ends of Eretz Yisrael (and needed to be strong to protect from invaders from the south and north. The Yarden and Yam ha'Gadol protected Yisrael from the east and west.
When did they fight with Leshem?
Radak (Shoftim 17:1): This was after Shimshon died.
Why did they fight with Leshem?
Rashi (Devarim 33:22, Radak): It was because their land did not suffice for them.
Malbim: Because they inherited at the end of Eretz Yisrael near the border, they were not able to dispossess the Emori'im (Shoftim 1:34), only in the west. Later, in the days of the Shoftim, they conquered the east.
QUESTIONS ON RASHI
Rashi writes that they conquered Leshem after Yehoshua died. How is it written here? Yehoshua wrote his Sefer (Bava Basra 14b)!
This is like Abarvenel's second Perush (Shoftim 17:1) that the end of Sefer Shoftim occurred after Pelishtim incarcerated Shimshon, and before Eli. According to his first Perush, it was after Yehoshua died, and before Osni'el, i.e. shortly after Yehoshua died! (PF)
This seems like R. Shimon (Bava Basra 15a), who says that Yehoshua wrote the last eight verses of the Torah [starting with Moshe's death]. Why did he not say that Yehoshua had Ru'ach ha'Kodesh to include what would occur in the future? Perhaps this is because it would have removed Bnei Dan's Bechirah (ability to choose whether or not to do so. - PF)