Gravitation law paradox for very close objects?

The inverse-square law holds for spherically symmetric objects, but in that case the main problem is that $r$ is the distance between their centers. So "very close" spheres are still quite a bit apart--$r$ would be at least the sum of their radii.

For two spheres of equal density and size just touching each other, the magnitude of the gravitational force between them is $$F = G\frac{M^2}{(2r)^2} = \frac{4}{9}G\pi^2\rho^2r^4\text{,}$$ which definitely does not go to infinity as $r\to 0$ unless the density $\rho$ is increased, but ordinary matter has densities of only up to $\rho \sim 20\,\mathrm{g/cm^3}$ or so.

Tests of Newton's law for small spheres began with the Cavendish experiment, and this paper has a collection of references to more modern $1/r^2$ tests.


Because atoms are not infinitely small.

The fact that we don't see infinite gravitational forces between two touching objects actually tells us some interesting things about the nature of ordinary matter.

As Stan Liou's answer quite correctly points out, for spherically symmetric masses the gravitational attraction depends entirely on their masses and on the distance between their centers. This is called the shell theorem.

For example, if you have two steel spheres with a diameter of one centimeter, placing them in contact means that their centers are one centimeter apart, and calculating the gravitational force from that and their mass (at a density of about 7.8 g/cm3) gives you a very small number that I'm not going to bother to calculate.

But gravitational attraction doesn't just apply to each sphere as a whole. It applies to any two massive particles. The particles within each sphere are attracted to each other, and each particle within each sphere is attracted to each particle within the other sphere. It happens that a spherically uniform object is gravitationally equivalent to a point mass at the center.

But matter is not uniform.

If the mass within each sphere were uniformly distributed at all scales (no atoms!), then having two spheres in contact with each other would mean that parts of one sphere would be infinitely close to parts of the other sphere. But that doesn't give you an infinite gravitational force. Consider a small subset of one sphere in contact with a small subset of the other. As you shrink the scale of the portions that you're considering, the force goes up as the inverse square of the size -- but the mass of the subsets goes down as the cube of the size. So that's consistent with what we see, and the shell theorem applies.

But if the mass were concentrated into infinitely small massive particles (zero-sized atoms), and those particles were able to come into direct contact with each other, then you could have two such particles with finite mass at zero distance. The gravitational force would be infinite, and ordinary matter as we know it probably could not exist.

In reality, matter is composed of small massive particles of finite size, so we don't see infinite gravitational forces. (Electrons, even if they're infinitely small, are repelled by their electric charge, so they can't get close enough to each other for the gravitational force between two electrons to be significant.)

So the fact that ordinary matter is able to exist, and that we don't see infinite gravitational forces between objects in direct contact, eliminates some possible models of how ordinary matter is constructed on very small scales.

(When I started writing this answer, I was thinking that it also eliminated the possibility of uniform distribution without atoms, but that turned out not to be the case.)