Why did Rama kill Vali?

Vali, king of Kishkindha, chased a demon into a cave. After a year, his brother Sugriva believed him dead, and took the throne.
But Vali was alive. He drove Sugriva out, and took Sugriva's wife for himself.
Rama promised Sugriva his help. In return, Sugriva would help him find Sita.
During the brothers' duel, Rama's arrow struck Vali down. Dying, Vali demanded a reason. Rama answered: you took your brother's wife, and a king must punish such a wrong.
Source: Valmiki Ramayana. Episodes found only in later retellings are marked as such.