Why was Eretz Yisrael initially given to the Seven Nations?

May our Torah provide an Iluy to the Neshamot of those murdered in Eretz Yisrael, merit that those taken captive be safely and quickly returned, merit that those injured be given a speedy Refuah Shleima, merit that the Chayalei Tzahal be safe and successful, and merit that we reach a swift and peaceful end to this war.