Why do we need Cities of Refuge when Moshiach comes if at that time there will be no more death?
The Lubavitcher Rebbe answers that we will need the Cities of Refuge for all the people who have killed inadvertently over the course of exile. They will need to go to the city of Refuge to protect themselves from the "blood redeemer" (Go'el Ha-dam). See there for the explanation of why the "blood redeemer" taking revenge is not incompatible with the Days of Moshiach.
AskMoses.com adds that at the beginning stages of the Messianic Era (see Shaloh mentioned here), before the Resurrection of the Dead, the Cohen Gadol can still die, thereby freeing the accidental murderers from the Cities of Refuge.
The Aruch Laner answers that natural death will no longer exists but if someone kills someone death will still happen.
The Chasam Sofer in Toras Moshe on Parshas Shoftim says that maybe you can answer that the Geirim (proselytes) that come to Klal Yisroel will not reach the level of death not affecting them, but will be only counted as Jews and therefore the Cities of refuge will be for them.
The Shnei Luchos Habris known to us by his acronym as the Shlah answers there are many different time periods after Moshiach comes, the city of refuge will be needed for the initial stages and only later will death disappear from the world.
The Meshech Chachmah answers that there are two ways Moshiach can come we bring him with our good deeds or time runs out and history runs its course and Hashem is forced to bring Moshiach even though we are undeserving. In the case we are undeserving the outcome will be as the Rambam says the World will continue as it is accustomed and Death will still happen and that is why the city of refuge will be needed if we get Moshiach by History runing its course.
I'm assuming included in your question is why is there a command to add three cities of refuge when Moshiach comes (Deuteronomy 19:8 with Rashi). If so, Rav Daniel Glatstein dedicated an entire shiur to this question (starting 15:30), and came up with eight reasons (some of which are in the other answers). Even if I'm wrong in understanding your question, these answers still address your question as written.
- When Moshiach comes there will be no more wars (and murderers), however that doesn't mean that there won't still be accidental deaths (Be'er BaSadeh to Deuteronomy 19:8; Aruch LaNer (Makkos 9b s.v. בגלעד), as SimchasTorah brought).
- We won't need them, even though we must establish and continue to have them. It's simply a gezeiras hakasuv, a decree of the Writ (Minchas Chinuch § 520).
- Those who killed these days by accident will need to go to exile when Moshiach comes (Yedei Moshe to Devarim Rabbah 4:30; as Menachem answered in the name of the Lubavitcher Rebbe; Rav Glatstein didn't reference this but I found the Chida in his Penei Dovid (Shoftim § 11) says this in the name of the Sheivet Mussar).
- When Moshiach comes, everyone will miraculously become good, so no one will die. However, we aren't supposed to rely on miracles, and therefore we have to separeate the cities of refuge as if there won't be a miraculous existence (Rav Glatstein didn't say who he was quoting).
- All the prophecies about the supernatural nature of Moshiach are for the Jewish people. All those who will want to convert to Judaism at that time will not be subject to that miraculous existence, and will still be able to accidentally kill (Maskil LeDovid to Deuteronomy 19:8; Chasam Sofer in Toras Moshe to Deuteronomy 19:8, as SimchasTorah brought).
- Chazal say that Ba'alei Teshuva are on a higher level than those who never sinned. As such, those that never sinned will need the cities of refuge, unlike the Ba'alei Teshuva of the end of days (Chasam Sofer Al HaTorah to Deuteronomy 19:8).
- As the process of Moshiach unfolds and the land of Israel is expanded to include the entire world, there will still be a natural order of things in which the cities of refuge will be necessary (Shlah HaKadosh (Hakdamas Toldos HaAdam Beis Dovid), as SimchasTorah brought).
- If Moshiach comes at his designated time, there won't be a need for the cities of refuge. However, the verse is referring to a scenario where Moshiach is bought early, for Kabbalistic reasons there will be a need for the cities of refuge, or explained simply the world won't be changed to a supernatural state but rather continue as it does now. This is why the verse is written "if Hashem expands your borders", and not "when Hashem expands your borders". (Arizal (Lukkutei Torah parshas Shoftim, brought by Shlah HaKadosh (ibid), brought by Maskil LeDovid (ibid); Meshech Chochmah to Deuteronomy 19:8, as brought by SimchasTorah, although if you see he says the opposite of how SimchasTorah described it, and instead like the Arizal).