To the extent that scientists understand gravity, it is a product of geometry; gravity is a curvature in the space-time continuum, and the extent of the curvature is determined by the extent of an object's mass. The curvature around Earth makes the moon stay nearby, and the curvature around the sun causes the planets of our solar system to orbit it.
An analogy often used to help people understand gravity is this: place a large marble on a rubber sheet and observe how the sheet indents; the marble represents the sun and the indentation represents its gravitational pull. Place a smaller marble representing Earth on the sheet and observe how the indentation of the rubber sheet causes the smaller marble to roll toward the larger.
As of 2015, though, science's understanding of gravity has not yet been reconciled with its understanding of particle physics. Dividing the two topics is a threshold called the Planck length, which is extraordinarily small. Anything smaller than the Planck length is best understood through a theory known as quantum mechanics, while anything larger is best understood using Albert Einstein's theory of relativity. Until science has a unified field theory reconciling relativity and quantum mechanics, science cannot honestly claim a full understanding of gravity.