The planets all orbit the sun in roughly the same plane varying between 3.38 degrees (mercury) and 7.15 degrees (Earth)
This is because the planets all condensed from the same cloud of debris which itself was orbiting the sun getting flattened to a disk as the sun rotated
Interestingly, Pluto, now not officially a planet did orbit out of plane by a larger amount, it also has a more squashed eliptical path which meant it actually dipped inside the orbit of Neptune during perehelion.