Kepler's third law was a pattern; Newton explained it, and in doing so turned every orbit into a scale for weighing the body at the center. You know from Gravity: Mass and Distance that more mass means more pull. More pull means a faster orbit.
Why it works
Take a small body on a circular orbit of radius $a$ around a mass $M$. Gravity supplies the centripetal force: $\frac{GMm}{a^2} = \frac{mv^2}{a}$, so $v^2 = \frac{GM}{a}$. The small mass $m$ cancels. One orbit takes $P = \frac{2\pi a}{v}$, so $v = \frac{2\pi a}{P}$. Substituting: $\frac{4\pi^2 a^2}{P^2} = \frac{GM}{a}$, which gives $$M = \frac{4\pi^2 a^3}{G P^2}.$$ The same result holds for ellipses with $a$ the semi-major axis. In the Sun's units (AU, years, solar masses), Earth's orbit makes every constant equal to 1, leaving $M = \frac{a^3}{P^2}$. (Strictly, $M$ is the sum of both masses; a planet adds almost nothing.)
Key idea
Newton's form of Kepler's third law: $M = \dfrac{a^3}{P^2}$ with $M$ in solar masses, $a$ in AU and $P$ in years; in SI units, $M = \dfrac{4\pi^2 a^3}{G P^2}$. The orbit measures the mass at the center.
Worked examples
Worked example: A star's mass
A planet orbits a distant star at $a = 2$ AU with a period of $2$ years. What is the star's mass?
- $M = \frac{a^3}{P^2} = \frac{2^3}{2^2} = \frac{8}{4}$.
- $M = 2$ solar masses.
Answer: $2$ solar masses.
Worked example: Weighing Jupiter
Jupiter's moon Io orbits at $4.22 \times 10^{8}$ m every $1.769$ days. Find Jupiter's mass.
- Period in seconds: $1.769 \times 86{,}400 = 1.528 \times 10^{5}$ s.
- $a^3 = (4.22 \times 10^{8})^3 = 7.52 \times 10^{25}\,\text{m}^3$.
- $M = \frac{4\pi^2 \times 7.52 \times 10^{25}}{6.674 \times 10^{-11} \times (1.528 \times 10^{5})^2} = 1.90 \times 10^{27}$ kg, about 318 Earth masses.
Answer: $1.90 \times 10^{27}$ kg.
Common mistake
It seems natural that a heavier satellite would orbit faster or slower, but the orbiting body's own mass cancels out of $\frac{GMm}{a^2} = \frac{mv^2}{a}$. A space station and a dropped bolt beside it orbit together. That is why an orbit weighs the central body. Check: the Moon (about $1\%$ of Earth's mass) and a tiny satellite at the Moon's distance would have almost exactly the same 27-day period.
This is how astronomers know the masses of the Sun, the planets with moons, distant stars with planets, and the black hole at the center of our galaxy.