Essentially, gravity is an attractive force between objects. Most people are familiar with gravity as the reason behind things staying on the Earth's surface, or "what goes up, must come down," but gravity actually has a much vaster significance. Gravity is responsible for the formation of our Earth and all other planets and for the movement of all heavenly bodies. It is gravity that makes our planet revolve around the Sun, and the Moon revolve around the Earth.
Though humans have always been aware of gravity, there have been many attempts to accurately explain it throughout the years, and theories must regularly be improved upon to account for previously unconsidered aspects of gravity. Aristotle was one of the first thinkers to postulate the reason for gravity, and his and other early theories relied on a geocentric model of the universe, with the Earth at its center. Galileo, the Italian physicist who made the first telescopic observations supporting a heliocentric model of the solar system, with the Sun at the center, also made strides in the theory of gravity around the turn of the 17th century. He discovered that objects of varying weights fall towards the Earth at the same speed.
In 1687, English scientist Sir Isaac Newton published his law of universal gravitation, which is still used to describe the forces of gravity in most everyday contexts. Newton's first law states that the force of gravity between two masses is directly proportional to the product of the two masses and inversely proportional to the square of the distance between them, or mathematically: F=G(m1m2/d2), where G is a constant.
Newton's second law states that gravitational force is equal to the product of a body's mass and its acceleration, or F=ma. This means that two masses that are gravitationally attracted to each other experience the same force, but that it translates into a much greater acceleration for a smaller object. Therefore, when an apple falls towards the Earth, both the Earth and the apple experience equal force, but the Earth accelerates towards the apple at a negligible speed, since it is so much more massive than the apple.
Around the late 19th century, astronomers began to notice that Newton's law did not perfectly account for observed gravitational phenomena in our solar system, notably in the case of Mercury's orbit. Albert Einstein's theory of general relativity, published in 1915, resolved the issue of Mercury's orbit, but it has since been found to be incomplete as well, as it cannot account for phenomena described in quantum mechanics. String theory is one of the foremost modern theories to explain quantum gravity. Though Newton's law is not perfect, it is still widely used and taught because of its simplicity and close approximation of reality.
Because gravitational force is proportional to the masses of the two objects experiencing it, different heavenly bodies exert stronger or weaker gravitational force. For this reason, an object will have different weights on different planets, being heavier on more massive planets and lighter on less massive planets. This is why humans are much lighter on the Moon than they are on the Earth.
It's a popular misconception that astronauts experience weightlessness during space travel because they are outside the field of gravitational force of a large body. In fact, weightlessness during space travel is actually achieved because of free fall — the astronaut and the space shuttle or rocket are both falling (or accelerating) at the same speeds. The same speed gives the notion of weightlessness or floating. This is the same concept as a person on a "free fall" ride at an amusement park. Both the rider and the ride are falling at the same speed causing the rider to seem as though he is falling independent of the ride. The same feeling can be experienced while riding an airplane or an elevator that suddenly breaks from its normal rate of decent.