How is it that all planets (and moons) in our solar system are in equilibrium orbits? Previously, I was told that in order for any bodies to orbit each other for over a long period of time, the orbital period, distance and masses have to be precisely matched such that the bodies won't eventually collide and forming larger bodies or being swung out of orbit.

How is it then, that all 8 planets (and countless dwarf planets), and their moons, and the Sun are all in such equilibrium for over thousands of years (if not millions)? Could it be possible what we see today are what's left, i.e. countless planets or moons have been swung out of the Solar System and collided, until a stable (relatively speaking) system is reached as we observe today?
I think at our current stage of solar system evolution, because of the fact that we have been able to evolve to our current level of sophistication, it could be considered to be very stable and in a very calm period in its evolutionary history. Unstable objects usually will be flung out very early on in the formation of such a system, hence why we do not see them today. However, just look at the Earth-Moon evolutionary history. It is theorised that our current Moon was captured due to a collision between Earth and perhaps a Mars (or similar size) object. This is anything but stable.

The reason why, is of course, related to gravity. Or more correctly, the gravitational potential of the system. All systems want to thermalise (in the same sense that a room of air molecules want to reach a thermal equilbirium). Although our solar system is anything but thermalised, it is constantly working to achieve this. Hence, why, at our present state of the solar system's evolution, we seem like we are in a fairly calm state. At this state, to go into more depth, we can employ Bertrand's theorem which tells us that for a central potential with an $r^{-1}$ dependance on radial distance the orbits will be stable. The stability of orbits in three spatial dimensions is due to the fact that the gravitational potential decreases with distance $r$ as $r^{-1}$.