There is a popular story that Newton was sitting under an apple tree, an apple fell on his head, and he suddenly thought of the Universal Law of Gravitation. As in all such legends, this is almost certainly not true in its details, but the story contains elements of what actually happened.
What Really Happened with the Apple?
Probably the more correct version of the story is that Newton, upon observing an apple fall from a tree, began to think along the following lines: The apple is accelerated, since its velocity changes from zero as it is hanging on the tree and moves toward the ground. Thus, by Newton's 2nd Law there must be a force that acts on the apple to cause this acceleration. Let's call this force "gravity", and the associated acceleration the "accleration due to gravity". Then imagine the apple tree is twice as high. Again, we expect the apple to be accelerated toward the ground, so this suggests that this force that we call gravity reaches to the top of the tallest apple tree.Sir Isaac's Most Excellent Idea
Now came Newton's truly brilliant insight: if the force of gravity reaches to the top of the highest tree, might it not reach even further; in particular, might it not reach all the way to the orbit of the Moon! Then, the orbit of the Moon about the Earth could be a consequence of the gravitational force, because the acceleration due to gravity could change the velocity of the Moon in just such a way that it followed an orbit around the earth.
By such reasoning, Newton came to the conclusion that any two objects in the Universe exert gravitational attraction on each other, with the force having a universal form:

The constant of proportionality G is known as the universal gravitational constant. It is termed a "universal constant" because it is thought to be the same at all places and all times, and thus universally characterizes the intrinsic strength of the gravitational force.
Weight and the Gravitational Force
We have seen that in the Universal Law of Gravitation the crucial quantity is mass. In popular language mass and weight are often used to mean the same thing; in reality they are related but quite different things. What we commonly call weight is really just the gravitational force exerted on an object of a certain mass. We can illustrate by choosing the Earth as one of the two masses in the previous illustration of the Law of Gravitation:

Thus, the weight of an object of mass
m at the surface of the Earth is obtained by multiplying
the mass m by the acceleration due to gravity, g,
at the surface of the Earth. The acceleration due to gravity is
approximately the product of the universal gravitational constant
G and the mass of the Earth M, divided by the
radius of the Earth, r, squared. (We assume the Earth to
be spherical and neglect the radius of the object relative to the
radius of the Earth in this discussion.) The measured gravitational
acceleration at the Earth's surface is found to be about 980
cm/second/second.