All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger.
The first prayer prescribed in Islam was the Thuhr prayer; it is for this reason why it is called Thuhr, from the Arabic verb Thahara, which means to appear. Some scholars refer to it as 'the first prayer' because it was the first prayer which the angel Jibreel (Gabriel) prayed with the Prophet after the prayer was ordained on the night journey, when he ascended to the heaven; this is reported by some companions and some righteous predecessors from the second generation after the companion.
Besides, At-Tabaraani reported that the first prayer which was ordained on the Prophet was the Thuhr prayer. Al-Hasan explained this in details; quoting the verse of Allaah (which means): {And establish prayer at the two ends of the day.}[Quran 11:114], he said: “The first prayer which the Prophet performed was the Thuhr prayer. Jibreel came to the Prophet and told him [quoting the Verse of Allaah (which means): {And indeed, we are those who line up [for prayer]. And indeed, we are those who exalt Allaah.}[Quran 37:165-166]. Hence, Jibreel stood in front of the Prophet and the companions stood behind him and the women stood behind the men.” Al-Hasan then said: “The Prophet led people in Thuhr prayer four Rak'ahs”. [Abdur-Razaaq]
As regards your question as to why the Prophet was commissioned a Prophet at the age of forty, then the answer is that it is at this age that a person's reasoning is complete, he becomes in the best state of mind and his strength is full. The Message is a heavy burden; it is for this reason that the Prophets were sent at the age of forty and this was not peculiar to the Prophet . Additionally, Allaah does whatever he wishes and He is the Most Wise.
Allaah Knows best.