3 Answers
3

It is because a sphere is the distribution of matter in which potential energy is the more uniformily distributed around the center of gravity, which means that it is the most stable distribution that exists.

Adding to the previous answer, consider the surface of the Earth. Any deviation from a spherical shape is either an indentation (canyon, valley) or a bump (hill, mountain). Any such deviation that's too big is smoothed out by gravity; a 100-kilometer mountain would collapse or sink, and a 100-kilometer deep valley would be filled in. The result is that there are some relatively small deviations (tiny bumps like the Himalayas), but the overall shape is very nearly spherical.

It's the same for any other body large enough to have significant gravity. Small moons and asteroids can be quite irregular, and rapidly spinning bodies can be significantly flattened, but most coherent bodies are very nearly spherical.

In short, it's because gravity is "round". That is, it only depends on the distance between objects. All objects that are at a particular distance are attracted with the same acceleration, so we'd say it's constant on a sphere and thus, in a way, it's "round". This isn't the whole story, of course. Things aren't perfectly round because of effects like rotation. But if gravity were left to itself, they'd tend towards perfect spheres.

In physics, we tend to say these objects are in hydrostatic equilibrium. In fact, this is part of the new IAU definition of a planet. What it means is that the pressure of a star/planet balances gravity at each point, or each distance from the centre of gravity. Because gravity is round, the pressure gradient must also be round. This only applies when gravity is strong enough to force things into shape. A brick has its own self-gravity, but obviously it isn't nearly strong enough to turn the brick into a near-sphere. This is also true of smaller solar system bodies like some asteroids. They aren't quite big enough for the gravity to force them to match the shape of gravity.