David and Shlomo instituted Boneh Yerushalayim over the Shechinah, and after the churban it became a request that Yerushalayim and the Beit HaMikdash be rebuilt. Hatov vehametiv was instituted when the dead of Beitar were buried, as the Rosh also explains. After Birkat HaMazon, the Chafetz Chaim, zt"l, explained why we say Harachaman. From the booklet Seudah of Rabbi David Shalom Naki, shlit"a.