How do computers predict eclipses?

Astronomers first have to work out the geometry and mechanics of how the Earth and Moon orbit the Sun under the influences of the gravitational fields of these three bodies. From Newton's laws of motion, they mathematically work out the motions of these bodies in three-dimensional space, taking into account the fact that these bodies have finite size and are not perfect spheres, and that the Earth and Moon are not homogeneous bodies. From careful observation, they then feed into these complex equations the current positions and speeds of the Earth and Moon, and then program the computer to "integrate" these equations forward or backward in time to construct ephemerides of the relative positions of the Moon and Sun as seen from the vantage point of the Earth. Eclipses are specific configurations of these bodies that can be identified by the computer. Current eclipse forecasts are accurate to less than a minute in time over a span of hundreds of years.