Joshua 19:47
And the coast of the children of Dan went out too little for them: therefore the children of Dan went up to fight against Leshem, and took it, and smote it with the edge of the sword, and possessed it, and dwelt therein, and called Leshem, Dan, after the name of Dan their father.
Joshua 19:47 belongs to the account of Joshua dividing and settling the Promised Land among the tribes of Israel. The division took place after Joshua, when about eighty years old, had led Israel through the Jordan. The Captain of Jehovah's hosts was with him, setting Israel in a fair way to conquer all their foes and to find the promised rest.
The allotment in the verse shows that a lot is a portion or division assigned by lot. Such an allotment is ultimately determined by divine providence. Leshem is also called Dan, and the names mean the same thing. The Danites took and possessed the city even though it lay outside the territory assigned to their tribe. The city's having both names explains how Moses could refer to Dan before the Danites conquered Leshem.
Israel might have possessed the land soon had they been faithful. But general backsliding after Jericho brought repeated captivity instead of prosperity. Those captivities brought years of adversity instead of the promised rest.