What is the mathematical reasoning behind the inverse square law of two charges? The Hon. Henry Cavendish performed an experiment with two spheres, by which he proved that no electric force is produced inside a hollow charged sphere. In other words, proving that no electric field is produced inside the sphere, means that the charge present on the surface is in equilibrium. How does it prove the inverse square law?
 A: Let's start with terminology, when I say charged I mean electrically or gravitationally charged (that is with mass). 
There's a theorem called the shell theorem that proves that if you have a force proportional to the inverse  square of  the distance then inside a uniformly charged spherical shell the field is zero. You can find a good discussion and some proofs of the theorem  here. Notice that this does not proves directly that if the field is zero then the force goes like $1/r^2$, in fact it proves the opposite: if force is like $1/r^2$ then the field is zero. So one have to compute the field inside the shell for a generic force $f(r)$ and see that the only case where the field is zero is when $f(r) \propto 1/r^{2}$.
The first man to do this was Newton in his Principia. He did it for an attractive force which in electrostatics corresponds to a positively charged shell and a negatively charged test charge or viceversa. You can do it for the repulsive case just changing the sign of a charge, obtaining both shell and test charge postive or negative. 
Newton first proved the shell theorem (note that he didn't have the concept of field so he proved that the force inside the shell was zero), then he calculated the force inside the shell for other particular forces (proportional to $r$, $1/r^3 $, $1/r$) and at the end worked out the general case. You can see a discussion of his work in Chandrasekhar's book: Newton's Principia for the common reader, where Chandra basically translates the Principia in modern mathematical terms and expand explanations. The treament of these things is in a chapter called "The superb theorems" . Sorry but I don't remember the number of the chapter.
