The law of gravity was discovered by Sir Isaac Newton. He formulated the law of universal gravitation and described how all celestial bodies attract each other with a force proportional to their masses and inversely proportional to the square of the distance between them. Newton's work on gravity was first published in his book "PhilosophiƦ Naturalis Principia Mathematica" in 1687, which also laid down his three laws of motion. This work unified the understanding of motion on Earth and in the heavens under the same gravitational principles.
While the concept of gravity had been explored by earlier scientists such as Galileo Galilei, who studied the acceleration of falling objects, and philosophers before him, it was Newton who formulated the law mathematically and comprehensively.
There is a famous story of Newton being inspired to consider gravity by observing an apple falling from a tree, though some historians debate its exact accuracy and suggest it may have been a later narrative for priority. Nonetheless, Newton's contributions are considered the foundational discovery of the law of gravity.