Manifestations of the gravitational pull of the planet Earth on massive objects:
The gravitational force between any two objects of mass $m_1$ and $m_2$ respectively located at $z_1$ and $z_2$ is given by:
\[ |\vec{F}_g|(|z_1 - z_2|) = \frac{Gm_1m_2}{|z_1 - z_2|^2}, \] where $G=6.67×10^{-11}$ [N m^2/kg^2] is Newton's gravitational constant and $|z_1 - z_2|$ denotes the distance between $z_1$ and $z_2$.
In our case it is the two masses are:
If this weren't but a fleeting sidenote on first principles, I would explain clearly what the $z$-coordinate system looks like and how these distances are measured. For our current purposes, it is sufficient to say that the effective gravity force on $r$ is equal to \[ F_{gy} = - \frac{ G M_{earth} m_{r} }{|R|^2} = - \frac{ 6.67×10^{-11} \cdot 5.9721986x10^24 \cdot 0.002 }{|6.3675×10^6|^2} = - 0.0196495... \text{ [N]} , \] where we used the radius of the earth as the “effective distance” between $r$ and the sum of all the earth particles, and plugged in the masses of the two objects verify. A key point to all of the subscript $y$ which means that we are talking about our $(x,y)$ coordinate system centred below your toe. In that coordinate system, the positive $y$-direction is up towards the sky, and the downwards direction is associated with negative $y$. Newton's law says that the force of gravity is downwards towards the centre of the earth so we need to put the minus sign in there.
Ok. Half the job is done now. We know the force acting on the carton so we can calculate its acceleration $a_y$ from Netwon't law $\vec{F}=m\vec{a}$, which says that for a given force acting on an object, the amount of acceleration is inversely proportional to the mass of the object. Here we are using the notion of inertial mass, from the greek “inertia” meaning the tendency to resisting change.
In general forces and accelerations are vectors, but our case we are dealing only with forces in the $y$ direction. Because we ignore the effects of air-friction, the only force acting on $r$ will be the force of gravity so we can say: \[ \text{total} F_{y} = F_{gy} = - 0.0196495 = m_r a_y \text{ in units [N] = [kg][m/s^2] } \] \[ \text{total} F_{x} = 0. \] Rearranging to solve for $a_y$, and substituting the mass of the carton (two grams) we get: \[ a_y = - 0.0196495/ 0.002 = -9.824.. \approx -9.8. \]
The astute reader will notice that we first multiplied by $0.002$ [kg] (the mass of the roach) and then in the second step we divide by $0.002$ [kg], so why do we even bother then? Indeed, this is precisely where this 9.81 comes from. People realized that for most situations the distance from the centre of the earth $R$, the mass of the earth $M$ and the newton's gravitational constant $G$ are constant so people defined $g$ as follows: \[ g=\frac{GM_{earth}}{R^2} \approx 9.81, \text{ in units [m/s^2] } \] and all you have to remember is that when an object is undergoing uniform accelerated motion due to the force of gravity then its $y$-acceleration is going to be $9.81$ [m/s^2] downwards. My Himalayan brothers living at high altitudes and my Dutch brothers living in below the sea level will have to adjust their $g$ constant to correct for their different distance from the centre of the earth.
How did Newton come up with that formula? He looked at the elliptical motion of the planets and realized that the force between them must be an inverse square law.