Hubble’s law explains that the reason most galaxies are moving away from one another is because the whole universe is expanding. Pick any two galaxies at random, and the chances are they’re moving away from each other.Â
According to Western Washington University, when Edwin Hubble discovered that  the universe is expanding, he explained it by drawing an analogy with a fruit cake baking in an oven. As the cake rises, all the raisins move further apart. In the same way, as the universe expands, the galaxies within it are moving further apart.
Of course, the universe isn’t as simple as a cake, and it took years of careful work — both theoretical and observational — to establish exactly what’s going on.
Measuring the distance between galaxies
As recently as 1920, scientists such as Harlow Shapley believed that galaxies we see in the sky are much smaller objects located on the outskirts of our own galaxy, rather than very distant objects similar in size and structure to the Milky Way.Â
That year saw a “great debate” on the topic between Shapley and another astronomer, Heber Curtis, who held something closer to the modern view, according to The Sky At Night Magazine. But the outcome of this debate, held at the Smithsonian Museum in Washington D.C., was inconclusive. At that time, observations simply weren’t good enough to establish galactic distances with any confidence.
It was Edwin Hubble who broke the deadlock, when he succeeded in measuring the distance to the Andromeda galaxy in 1924. He did this by observing a certain type of pulsating star called a Cepheid variable, which exhibits a close relationship between intrinsic luminosity and pulsation frequency.Â
So knowing the frequency tells you the luminosity, and comparing this with the observed brightness tells you the distance. When Hubble did this for Cepheids in the Andromeda galaxy, it became clear that it must lie well outside the Milky Way, according to Australia Telescope National FacilityÂ
That was Hubble’s first discovery. The second was even more momentous.
Hubble’s law
As well as measuring the distances to other galaxies, Hubble also studied their “redshift”, according to APS Physics. This is a property of the light spectra emitted by astronomical objects that arises from a phenomenon called the Doppler shift, according to The European Space Agency.Â
Think of the sound a vehicle makes as it whizzes past you. As it’s approaching the sound is higher pitched, then as it recedes into the distance it’s lower pitched. What happens is that sound waves are bunched up when they’re moving towards you, and stretched out when they’re moving away. It’s the same with light waves, except that we perceive the difference as a change in color instead of pitch.
Astronomical spectra typically display a pattern of emission and absorption lines, which are produced at well-defined wavelengths. But if the source is moving away from us, we see these lines shifted towards the red end of the spectrum — hence the term “redshift”.Â
Measuring the amount of this shift gives a good indication of how fast the object is traveling away from us. Hubble’s great discovery, in 1929, was that a galaxy’s redshift is proportional to its distance — a result now known as “Hubble’s law”, according to Western Washington University. This was hugely significant for two reasons.Â
First, it accorded with theoretical predictions, made around the same time, that the universe is in a constant state of expansion.
Second, it gave astronomers a new way of measuring the distance to galaxies that were too far away for the Cepheid method, simply by measuring their redshift, according to NASA’s Starchild Team .
Galaxy clustering
When we say “the universe is expanding”, we’re referring to the fabric of space itself. While this expansion carries all the material objects in the universe along with it, these can still interact with each other via the force of gravity, according to Scientific American. Gravity holds individual galaxies together, and the same force can also bind multiple galaxies together in galaxy clusters, according to NASA.Â
The Milky Way, for example, is part of a relatively small cluster called the Local Group, which contains around 85 gravitationally bound galaxies — most of them very small, according to Astronomy Magazine. The largest and best known of these is the Andromeda galaxy, which is actually traveling towards the Milky Way — in other words, it has a “blueshift” rather than a redshift. Eventually, a few billion years from now, the two will crash into each other and merge into a single huge galaxy.
Related: How many galaxies are there?