Sefer Hachinuch (mitzvah 410) explains as follows:
Murder is an extremely severe sin, since it destroys the fabric of society. So one who killed, even accidentally, deserves the death penalty for having committed such a terrible act. Instead, though, the Torah commutes his sentence to exile, the pain of which is almost as harsh as that of death: it means a permanent (or near-permanent) separation from friends, family, and birthplace.
This exile also serves two other purposes: it keeps him safe from the goel hadam (the "avenger of blood" who is out to kill him); and it also offers the other relatives of the victim some closure, so that they don't have to see the person who killed their relative day in and day out.
Why is he sent to live specifically among the Levites? (All of the cities set aside for them, 48 in all, are considered Cities of Refuge.) This, the Sefer Hachinuch says (mitzvah 408), is for the following reasons:
The Levites are holy people, and therefore their lands are holier than the rest of Eretz Yisrael. This extra measure of sanctity helps to atone for his grave sin of murder.
They are also consummately wise and moral people, and they therefore will not shun or harm him while he's living among them.
He doesn't explain why the goel hadam is given license to kill the accidental murderer. But possibly it's based on the point above, about murder being so destructive of human society. Since a Jewish court can apply the death penalty only very rarely (because to do so requires witnesses, a proper warning, and a whole rigmarole that is actually deliberately somewhat slanted in favor of the accused, so as to avoid bloodshed as much as possible), Hashem provides an approved extrajudicial method of dealing with the situation and dispatching the offender (while at the same time, balancing this by also providing a way for him to save his life).