How did Newton discover the theory of gravity