A study shows how ancient Egypt struggled with drastic changes in the climate