אמר רב יוסף תדע דהטוב והמטיב לאו דאורייתא שהרי פועלים עוקרים אותה
R' Yosef says (Brachot 46a) that the fourth blessing of birkat hamazon, “Hatov vehametiv”, must be rabbinic rather than required by the Torah. His argument is that all-day workers (who must not waste time while “on the clock”) omit this blessing from after their meals, and if the Torah required it, it could not be omitted even in this situation. After this, the gemara brings several other, similar, proofs why “Hatov vehametiv” is rabbinic.
The implication of all this is that all three of the previous blessings are from the Torah. This is hard to understand. In particular, the third blessing is about the rebuilding of Jerusalem. Jerusalem did not become the site of the Temple or national capital until hundreds of years after the Torah was given. For most of the interim period, the city Shiloh played the role we associate with Jerusalem. So how can the Torah require us to recite the blessing this way?
Let us look at the Torah's source for birkat hamazon, and see where each of the three blessings can possibly come from.
“You shall eat, and be sated, and bless Hashem you God for the good land which He has given you.” (Devarim 8:10)
The second blessing is easiest to justify. It is about the land, and we are explicitly told to thank God for the land.
The first blessing is about food. We are not told explicitly to bless about food. But the context of birkat hamazon is surely relevant. If we thank God for the land, but only after eating, then why is the land important to us? Clearly, it is important in that it provides us with food. And thus, we have a separate blessing which thanks God for food. Could this thanks not have been included in the “land” blessing? It could, and (according to some opinions) the bracha me'ein shalosh we say after eating cake is exactly such a “combined” blessing. But for birkat hamazon, the accepted text has the topics separated into multiple blessings.
Now to the third blessing. Where in Devarim 8:10 is there any hint of Jerusalem?
I think the answer is in the last few words of the verse, “which He has given you”. The second blessing thanks God for the land, the third blessing thanks God for our control of it. Only when we control the land can we enjoy its produce; if we are exiled or oppressed, we are not benefiting from it. Jerusalem is simply the current symbol of that control. Once God “has mercy on Israel... Jerusalem... Zion... the kingdom of the house of David... the Temple” (to quote the blessing), then we will be returned from exile, living peacefully with the land of Israel under our control.
The “kingdom of the house of David”, which seems to be the most peripheral item on the list I just quoted, may actually be the most important. According to the Shulchan Aruch, if you forget the phrase “kingdom of the house of David”, your entire birkat hamazon is invalid. Similarly, the Yemenite text of birkat hamazon has a very different third blessing from ours, which puts even more emphasis on the “kingdom of the house of David” than we do. I think we can explain this emphasis by saying that the blessing's basic theme is our control over the land, and if we leave this out the purpose of the blessing is not accomplished.
Now, for almost 2000 years we did not have control over the land of Israel. So, technically speaking, it was impossible to thank God for control. Instead, we have offered a prayer that control be returned to us. We still say this today, partly because changing established texts is difficult and fraught with danger, partly because our control of the land is still very incomplete.
Of course, we are forced to say that the third blessing did not always mention rebuilding Jerusalem. When the Temple was standing, it must have said something like “We thank you for preserving the kingdom of David in the holy city of Jerusalem”. Before the Temple was built, it must have said something similar about Shiloh. The exact wording would change from generation to generation. But the Biblically mandated idea – recognition that the land has been delivered into our control as a Divine gift – remains the same.
On a different note: Taking a broad look at birkat hamazon, we see the following rough pattern. In the three blessings we thank God for our food, for the farm which provided the food, and for the political circumstances which allow us to benefit from that farm. This list begins with the immediate and personal, and proceeds to the universal and abstract. In some ways, it reminds one of Maslow's hierarchy of needs, in which the lower needs must be satisfied before the higher ones.