It is somewhat of a mystery why people in early chapters of Genesis lived such long lives. There are many theories put forward by biblical scholars. The genealogy in Genesis 5 records the line of the godly descendants of Adam—the line that would eventually produce the Messiah. God possibly blessed this line with especially long life as a result of their godliness and obedience. While this is a possible explanation, the Bible nowhere specifically limits the long lifespans to the individuals mentioned in Genesis chapter 5. Further, other than Enoch, Genesis 5 does not identify any of the individuals as being especially godly. It is likely that everyone at that time period lived several hundred years. Several factors probably contributed to this.
Genesis 1:6-7 mentions the water above the expanse, a canopy of water that surrounded the earth. Such a water canopy would have created a greenhouse effect and would have blocked much of the radiation that now hits the earth. This would have resulted in ideal living conditions. Genesis 7:11 indicates that, at the time of the flood, the water canopy was poured out on the earth, ending the ideal living conditions. Compare the life spans before the flood (Genesis 5:1-32 with those after the flood (Genesis 11:10-32). Immediately after the flood, the ages decreased dramatically.
Another consideration is that in the first few generations after creation, the human genetic code had developed few defects. Adam and Eve were created perfect. They were surely highly resistant to disease and illness. Their descendants would have inherited these advantages, albeit to lesser degrees. Over time, as a result of sin, the human genetic code became increasingly corrupted, and human beings became more and more susceptible to death and disease. This would also have resulted in drastically reduced lifespans.