How exactly does gravity work?

You're quite right that the other fundamental forces of Nature possess mediator particles, e.g. the photon for the electromagnetic force. For gravity, a graviton particle has been postulated, and is included in the five standard string theories which are candidates for quantum gravity. From a quantum field theory perspective, the graviton arises as an excitation of the gravitational field. String theory, of course, postulates it arises in the spectrum of a closed string.


Mass certainly gives rise to a gravitational field, but many other quantities do as well, according to the field equations of general relativity. As you're a high school student, I'll present them as,

$$\underbrace{G_{\mu\nu}}_{\text{geometry}}\sim \underbrace{T_{\mu\nu}}_{\text{matter}}$$

Spacetime geometry, and hence the gravitational effects, are equated to the matter present in a system, which may include energy, pressure and other quantities other than mass.


From a general relativity standpoint, the gravitational field may be viewed, or interpreted, as the curvature of spacetime, which is a manifold, i.e. surface. If we take space to be infinitely large, then the gravitational field must extend indefinitely; otherwise where would we choose to truncate? Even from a Newtonian perspective, we see that given the equation,

$$F_g \sim \frac{1}{r^2}$$

gravity must extend infinitely, as we never reach the point $r=\infty$ where it is truly zero.


As you asked, if the graviton is postulated, what is the need for a field? Well, we know that particle number is not conserved; we can have virtual particle and anti-particle pair production, and as such the idea that a field propagates throughout space, and the particles are excitations of the field, is a more compatible viewpoint. In addition, the concept of a field arises because of locality. From empirical evidence we know gravitation and electromagnetism do not act instantaneously, at every point.


Since you don't fully understand the answer of JamalS, I'll try to explain it shorter and easier for you.

If all other forces of nature have some particles associated with them why should gravity be an exception?

No, it isn't an exception. Physicists believe that the particle for gravity (called graviton) does exist, it's just they haven't found it yet. Standard Model doesn't have gravity, but extended Standard Model may have. Thanks to string theory.

What exactly is the gravitational field and how does it spread over an infinite distance and cause the gravitational force to operate?

It is exactly the space and the time. How do space and time appear? Big Bang. How does gravity operate? A change of space and time give you a gravitation force. Like a change in position gives you velocity ($v=\Delta x$), a change in energy gives you work ($W=ΔKE$). A change is very important, it will give you another interesting entity. If you have studied differential, you now know how important it is: describing a change.

By referring a change of space and time, I don't mean like a car travels through cities from morning to afternoon. I mean the car reforms the shape of time and space itself.

From Wikipedia:

Matter changes the geometry of spacetime, this (curved) geometry being interpreted as gravity.

enter image description here


I don't think the other answers have clearly called out that we do not know. Yes, we do have the (rather wonderful) theory of general relativity (GR), which does an excellent job of explaining the effect of gravity.

It does this by relating the presence of mass (strictly "stress-energy") to the structure of space-time. It also states how that effect propagates through space and time. So from a classical perspective, space-time itself can be seen as a gravitational field.

What it does not say is how space-time is able to interact with mass.

We expect that a quantum field theory type process is involved, and a lot of work goes in to determining this. Relating GR and quantum theory is in fact the fundamental problem of theoretical physics.

One of the key problems in solving this is in fact the very success of GR - we lack experimental evidence of it failing and hence providing a lead on where to improve it via quantum effects.