It's a newbie question. How is the formula for force between two charges or gravitational force between two particles derived. Is it just intuition or is there any method used to derive these equations? For example I am not able to understand how is $r^2$ term of these formulas are taken.
Consider the gravitational force equation is not yet discovered. So what would be the steps someone need to reach in this formula?