We are obligated to designate six cities of refuge (“arei miklat” in Hebrew) among the cities that were given to the Levites. The purpose of these cities was so that one who killed another by accident could flee there to escape the wrath of the victim’s family members. Roads were clearly marked with signs saying “Miklat” so that people could always find their way there easily.
Three of the six cities were in Transjordan and were established by Moses. The other three were in Israel proper and were established by Joshua. In Messianic times, an additional three will be added as per Deuteronomy 19:9, “then you will add another three cities” (see Mishneh Torah Hilchos Rotzeiach chapter 8). Other Levite cities could also provide sanctuary, but only on request. Protection in an actual city of refuge was automatic.
The reason for this mitzvah is that we wish to save the fugitive from vengeance at the hands of the deceased’s heirs. The death, while tragic, was inadvertent and the manslaughterer does not deserve to die.
This mitzvah applies at a time of Jewish sovereignty in Israel; it is incumbent on the king and on the community as a whole. It is discussed in the Talmud in the second chapter of tractate Makkos, particularly on pages 9b-10a. It is codified in the Mishneh Torah in the eighth chapter of Hilchos Rotzeiach and is #182 of the 248 positive mitzvos in the Rambam’s Sefer HaMitzvos.