The most dangerous time period for a person in the Middle Ages was infancy. The mortality of babies was as high as 50%. This statistical information distorts the real picture of how long people of that time lived. The people who managed to survive infancy had a very good chance of living to 40, 50, and even 60 years.
On average, men died at the age of 45. Women lived for about 50 years and the most wealthy people even lived up to 65. Of course, there were more chances to die: pandemics, wars, and bad medicine which were also factors. And of course, life in the Middle Ages was much harder than it is now. But it was not as bad as many people think today.