This is described by Newton's Law of Universal Gravitation:
F = G * (m1 * m2) / r²
Where:
* F is the force of gravity
* G is the gravitational constant (a fixed value)
* m1 and m2 are the masses of the two objects
* r is the distance between the centers of the two objects
Notice that the force (F) is inversely proportional to the square of the distance (r²). This means that if you double the distance between the objects, the gravitational force between them will decrease to one-fourth of its original strength.
Example:
If you move twice as far away from the Earth, the gravitational force between you and the Earth will be four times weaker.
This inverse square relationship explains why the gravitational pull of the Sun is weaker on Earth than it is on Mercury, which is much closer to the Sun.