Although we have not traveled to all the planets nor to the Sun, we know their masses.
This means that gravitational acceleration is inversely proportional to the square of the distance from the centre of Earth.
More sophisticated tests use a torsion balance of a type invented by Eötvös.
A boulder falling toward the Earth is pulled by a stronger gravity force than the marble, since the boulder's mass is greater than the marble, but the boulder also has greater resistance to a change in its motion because of its larger mass.
Bernard; Smith, George Edwin 2002.
As early as 1645 had argued that any force exerted by the Sun on distant objects would have to follow an inverse-square law.