Actually, the answer is complicated.
Gravity isn't the only relevant aspect here. Gravity makes that you have to look at the combination of "sun + planet". They behave like 1 body together. But "sun + 10 planets" is like 10 different of these combined bodies: "sun + planet 1", "sun + planet 2", "sun + planet 3"...
Imagine it was different. Imagine a system of several planets rotating around the sun with all their rotational planes at different angles.
This system would be very asymmetric all the time. Now in general when asymmetric bodies rotate, then that motion is not stable. They tend to change their motion, that is, the rotational axis changes until it reaches the maximal inertia moment.
Take a plate or a stick and throw it up high while rotating it at a random angle. Then do it again with a very asymmetric thing. Watch how it's motion changes.
It becomes stable when the inertia moment is maximal.
https://en.m.wikipedia.org/wiki/Moment_of_inertia
For the system with several planets, the stability of the whole system is maximized when all the rotational planes are the same, because then the inertia moment of the whole system is maximal.