There are also a few more points to keep in mind when it comes to life expectancy in the past.
1. Their knowledge of medicine was woefully inadequate. Due to this, if there was a plague, an enormous number of people could be wiped out. Think of the bubonic plague.
2. Also keep in mind that their knowledge of how to keep healthy bodies was not good. To be honest, we are not that good as well.
3. There is also the issue of bearing children. Many women would die in childbirth. Also the child morality rate was extremely high due to the lack of knowledge, cleanness and nutrition.
When you average all of these things out, life expectancy was very low, much lower than ours.
The main reasons for this are better health care, better nutrition, and less physically stressful lives.
In the Middle Ages, medical care was pretty woeful. There were, of course, no antibiotics so any wound could become infected and potentially lead to death. As mentioned in your previous question, childbirth was very dangerous.
People in the Middle Ages, and especially the peasants, were extrememly poor compared to people today. They lacked proper nutrition, especially during the winter. Even the rich didn't know about proper nutrition and so ate quite unhealthily.
Finally, the work done by people in these times was very physically demanding. They could easily be injured (and lacked medical care to make them better). Even barring injury, they would wear themselves down through hard work combined with poor nutrition.