Eratosthenes was born in the country we now call Lybia, but in those days was called Cyrene.
19th century reconstruction of Eratosthenes' map of the known world, c.194 BC. Source: Wikipedia
Eratosthenes studied in Alexandria and claimed to have also studied for some years in Athens. In 236 BC he was appointed by Ptolemy III Euergetes I as librarian of the Alexandrian library, the center of science and learning in the ancient world, succeeding to Apollonius of Rhodes, in that post. He was the third chief librarian of the Great Library of Alexandria.
As chief librarian he read many documents and found out that at the Ancient Egyptian city of Swenet (known in Greek as Syene, and in the modern day as Aswan) that is located near the tropic of Cancer on June there is a well where on certain day of the year the sunlight goes down to the bottom of the well. He knew that in Alexandria there was no day that the great Obelisk did not produce shadow and he measured the shadow angle on the day the Sun was directly above the well in Aswan. He needed to know the distance from the well in Aswan to Alexandria and there several different versions of how he found out its value. The most popular one is that he send a slave to measure it in footsteps. The value that he used in his calculations was 8000 stadia (1 egiptian stadium is about 157.5 m, though the exact size of the stadium is often a theme of discussion).
With this information he measured the circumference of the Earth without leaving Egypt by assuming that Earth was a sphere and that the Sun rays are parallel when they arrive to Earth.
Eratosthenes assumed that Earth is a sphere and that the solar rays are parallel when they reach Earth.
If this was true then the angle (α) that the shadow made on the top of the obelisk in Alexandria would be the same as the diffrence in latitude between the two places.
Eratosthenes used a simple formula that relates the proportionality proportionality of distance on the meridian (d ) and the difference in latitude (α) to the relation between the perimeter (P ) and the angle of the circle (360º):
The shadow angle at the top of the obelisk measured by Eratosthenes was 7.2º, so he calculated that the Earth was about 252000 stadia.
If we assume the Egyptian stadium this is about 39 817 km (252808 stadium x 157.5 m/stadium) which has an error of less than 1% when compared to the accepted value of the meridional perimeter of Earth that is 40 007.86 km.
Eratosthenes' experiment was one of the most important experiments in antiquity and his estimate of the earth’s size was accepted for hundreds of years afterwards. It was, in fact, the most accurate estimate until Man was able to go to Space.