The Gemara in Berachos 26b brings a dispute regarding the origin of our obligation to daven.
Rabi Yosi ben Rabi Chanina says that the avos where misaken the tefillos. The Gemara quotes a braisa that supports this view and cites pesukim from which we derive that Avraham was mesaken Shacharis, Yitzchak was mesaken Minchah, and Yaakov was mesaken Ma’ariv. Rabi Yehoshua ben Levi disagrees, saying that tefillah was instituted to correspond to the korbanos.
There were two korbanos that were brought daily, the tamid shel shacharis and the tamid shel bein ha’arbayim. Shacharis and Minchah correspond to these two korbanos while Ma’ariv corresponds to the burning of the eimurim from the korbanos – which was performed at night. The tefillos of Musaf were instituted to correspond to the korban musaf that was brought on specific days. The braisa adds that the times to daven these tefillos correspond to the times that the korbanos were brought.
The Rambam (Hilchos Tefillah 1:5) seemingly brings down the opinion of Rabi Yehoshua ben Levi. The Rambam writes that the tefillos were mesaken to correspond to the korbanos. However, in Hilchos Melachim (9:1), the Rambam writes that Avraham davened Shacharis, Yitzchak davened Minchah, and Yaakov davened Ma’ariv. This implies that the Rambam sides with Rabi Yosi ben Rabi Chanina’s opinion, namely that the avos were mesaken tefillah.
The Kesef Mishnah, in Hilchos Tefillah, says that the Rambam paskens like Rabi Yehoshua ben Levi, that is to say that the tefillos were instituted to correspond to the korbanos. But the Lechem Mishnah there disagrees, opining that there is no indication from the Rambam that he paskens like the view that tefillos were instituted to correspond to the korbanos. This is because the Gemara in Berachos there says that even the opinion that holds that the avos instituted tefillah is in agreement that the rabbanan relied on the pesukim of the korbanos when they instituted the halacha that one must daven. Based on this we can suggest that there is no contradiction by the Rambam. The Rambam may pasken like Rabi Yosi ben Rabi Chanina that the avos instituted tefillah; yet the rabbanan relied on, and based the times on, the korbanos.
The Ohr Somayach, in Hilchos Tefillah (3:9), suggests another solution to this contradiction. He says that in fact we pasken like both opinions. The Gemara cites two braisos, both ruling in accordance with each opinion; thus we pasken like both of them. The Ohr Somayach says that according to the opinion that the tefillos were mesaken to correspond to the korbanos, if one forgot to daven Minchah he would not be able to daven two Shemoneh Esreis during Ma’ariv. Why? Because the halacha by korbanos is that once the day has passed one cannot bring that korban any longer. However, since we also pasken that tefillah was instituted by the avos, we pasken that one should daven two Shemoneh Esreis in such a situation.
The Maharitz Chayis, in Berachos 26b, suggests another solution. He says that in fact the Rambam does pasken like Rabi Yehoshua ben Levi that tefillah was instituted to correspond to the korbanos. Everyone agrees, though, that the avos davened these tefillos. The dispute in the Gemara only concerns the institution of the tefillos that we daven. Rabi Yehoshua ben Levi agrees that Avraham davened Shacharis, Yitzchak davened Minchah and Yaakov davened Ma’ariv. He disagrees on the issue of the reason why we daven, saying that that is not the reason. Therefore the Rambam, while writing in Hilchos Melachim about the avos, mentions that they davened. He did not mean to indicate that this is the reason why we daven today. The reason is, as the Rambam writes in Hilchos Tefillah, because the rabbanan instituted tefillah to correspond to the korbanos.
This is in accordance with what the Rambam writes in Pirush HaMishnayos in Chullin (end of the seventh perek). The Rambam writes there that we do not do any of the things that were done before mattan Torah unless it was commanded to us at mattan Torah. For example, the Rambam says that we do not refrain from eating gid hanasheh because Yaakov Avinu was banned from eating it. Rather, this is because we were commanded to do so at Har Sinai. The Maharitz Chayis explains that this applies to tefillah as well; we do not daven because our avos did, but rather because we were commanded to do so thereafter.