Nowadays everybody knows there are nine planets in our solar system, but that information was hard won. The planets that shine brightly in our sky, such as Venus and Jupiter, are easy to identify. However, the farther-out planets are almost invisible. In some cases, however, astronomers were able to infer their existence before actually spotting them!
In 1781, the planet Uranus was discovered, but there was something funny about its orbit. Careful observations showed that Uranus had a tendency to drift.
Well, think of it this way. If the sun only had one planet, that planet would have a pretty smooth orbital path. That doesn't mean it would have to be a circle, just that the planet's motion around the sun would be regular and fairly uniform.
Two planets make things a little more complex. Now our first planet is being pulled on not only by the sun's gravity but by the gravity of the second planet as well. Our first planet will have a slightly irregular orbit, because it is being tugged on by two different bodies.
That's true for the planets in our solar system: they all cause slight disturbances in each other's orbits. But even when astronomers canceled out the effects of all the planets known in 1781, they found Uranus was still drifting.
Could there be another planet beyond it that no one had ever seen? You bet. Predictions were made for where a new planet would be based on the irregularities in Uranus' orbit. Sure enough, in 1846 the first sightings were made...of Neptune, the eighth planet.