The idea of a spherical Earth was floated around by Pythagoras around 500 BC and validated by Aristotle a couple centuries later. If the Earth really was a sphere, Eratosthenes could use his observations to estimate the circumference of the entire planet.
Since the difference in shadow length is 7 degrees in Alexandria and Syene, that means the two cities are 7 degrees apart on Earth's 360-degrees surface. Eratosthenes hired a man to pace the distance between the two cities and learned they were 5,000 stadia apart, which is about 800 kilometers.