Here's how he did it:
* Observation: Eratosthenes noticed that on the summer solstice, the sun shone directly down a well in Syene (modern Aswan, Egypt). At the same time, in Alexandria, a different city further north, the sun cast a shadow. This indicated that the Earth was curved.
* Measurement: He measured the angle of the shadow in Alexandria and knew the distance between Syene and Alexandria. Using trigonometry, he calculated the circumference of the Earth.
Eratosthenes' measurement was remarkably accurate, only about 16% off the modern value. This was an incredible feat for his time, considering he only had simple tools and rudimentary knowledge of trigonometry.