I've heard elsewhere that he knew this because at that time, no shadow was cast in a well. A well isn't necessary to observe this though, since any container with parallel walls such as a box or a tube will not have a shadow when light comes from directly above it. Try it out yourself. He then assumed that the sun was so far off that its rays hit the earth in parallel. If you imagine all the lines from the surface of one ball to another, you can see that as the balls get further apart, all the lines become nearly parallel.
Parallel means that the lines all go in exactly the same direction.
He also assumed that the earth was shaped like a ball. He also knew that Syene was on the same meridian as the city of Alexandria. The earth is a ball that spins around a line called its axis. If you follow a meridian all the way around the earth you get a circle, like the equator. Finally, Eratosthenes knew that the distance between Alexandria and Syene was 5000 stadia, a Greek unit for measuring length.