The reason for this is that the formula
$$F_G = G\frac{m_1 m_2}{r^2}$$
technically only gives the gravitational force between two objects that are of point size, i.e. that have size zero. When $r = 0$, that is saying that you have two infinitely concentrated masses infinitely close together. Does this sound like a good description of the situation of an object resting on the surface of the Earth? Is the Earth an infinitely concentrated mass (i.e. a singularity)?
Hence, you can only unqualifiedly apply this formula when that we are talking of objects so far apart that their size is negligible and they are "approximately pointlike", such as a spacecraft far from the Earth, or the planets in the Solar System (e.g. the distance between the Earth and the Sun is on the order of 150 Gm, but the Sun itself is only about 1 Gm in size and the Earth, 0.012 Gm, so both can be treated as roughly pointlike).
To treat extended bodies, we must use a continuum-mechanical description. Instead of the above formula, we must use the more general gravitational field, $\mathbf{g}$, which has a vector value at each point in space, and we require that each infinitesimal part of the extended body act individually as an infinitesimal source of gravitational field:
$$\nabla \cdot \mathbf{g} = -4\pi G\rho$$
where $\rho$ is the mass density at a given point in space, and the left hand term is the field divergence, which basically describes how much locally each point acts as a source of field. Moreover, the gravitational field should be conservative:
$$\nabla \times \mathbf{g} = \mathbf{0}$$
. And then we can integrate these to obtian $\mathbf{g}$, and then the force $\mathbf{F}_G$ on an object by $\mathbf{F}_G = m\mathbf{g}$.
Despite that, however, there is a "saving grace" that allows one to more simply use the simple first formula reasonably well to treat the situation of the object on the Earth. Using the more proper, extended-body description of gravitation we just gave, you can prove that for a spherically symmetric mass distribution $m_1$ of radius $R$, that the gravitational force on a point-like object of mass $m_2$ at a height $h$ above its surface is
$$F_G = G\frac{m_1m_2}{(R + h)^2}$$
and to the extent you can consider Earth a spherical object, this formula says that in effect, you can treat the Earth as being equivalent to a point-like gravitator with all its mass concentrated at its center, and thus the $r$ going into the formula for the pebble-on-ground scenario should be the entire Earth's radius, i.e. the distance from its center to its surface, and not simply the contact distance between the surfaces of the two objects. This is about 6371 km, or $6.371 \times 10^6\ \mathrm{m}$, with units at the scale of a human being (1-2 m), or $6.371 \times 10^9\ \mathrm{mm}$, with units at the scale of a pebble (1-10 mm). So clearly, your gravitational force will be quite a bit less than infinity once you use that large number instead of zero :)