Summary: God commands Joshua to designate cities in the Land of Israel as cities of refuge for a person who had killed unintentionally but with some element of negligence. This fulfilled the command given to Moses in the book of Numbers (35:9-34). The tribe of Levi petitioned Joshua and Elazar, the high priest to fulfil God’s promise to designate cities for them.
In depth: The Torah rules that the tribe of Levi would not receive a portion of the land of Israel because ‘God is their inheritance’ and they will receive the offerings from the Temple together with the various tithes (Deuteronomy 18:1-2). They would however, live in six cities designated as ‘cities of refuge’ in addition to 42 other cities, together with their open spaces (Numbers 35:6-8). The Gemara explains that the additional 42 Levite cities also served as cities of refuge with some minor differences (Makkot 13a).
The number of additional Levite cities is the same as the number of encampments made by the Jewish people between Egypt and the land of Israel. This is not coincidental as the portion of the Torah describing the 42 encampments directly precedes the commandment regarding the Levite cities.
Rabbi Shlomo Kluger (d. 1869) explains that since at each of these encampments God turned the desolate wilderness into a place fit for living, the Jewish people were required to repay His kindness measure for measure by separating an additional 42 cities from their allotted land for the Levites, the servants of God.
With respect to the other six cities, the Tanaaic sage Jonathan ben Uzziel explains that after Aharon died, Amalek attacked the Jewish people once again. Some Jews fled back towards Egypt, retracing their steps by six encampments. Leaders from the tribe of Levi chased them and fought to bring them back. There were casualties on both sides and although the survivors returned, the tribe of Levi concluded that their losses were as a result of not mourning for Aharon properly (Targum Yonatan on Deuteronomy 6:10). While this was not intentional, they were still accountable for this lack of respect.
Similarly, the primary six cities of refuge gave sanctuary to those whose hands were guilty, but hearts were innocent.