How Do We Know the Distance to the Stars?
When we look at the night sky there is no simple, obvious way to accurately judge the distance to the stars. If we get any impression at all it is that the brighter stars are closer. But we now know that the stars are VERY far away, especially in everyday human terms.
If all stars were the same brightness things would be very easy. By looking at the relative brightness of the nearby Sun and the distant stars we could determine their distance. The only thing that affects the apparent brightness of identical objects is their distance. This will give the distance as a multiple of the distance to the Sun. But things aren't that simple and stars come in many different types with a wide range of actual brightnesses.
The first method that allowed us determine the distance to the stars was parallax, the apparent change in position as the viewpoint changes. As the Earth goes around the sun our vantage point shifts back and forth by a bit less than 200 million miles. This results in a shift of the angle to the stars. This produces a triangle with one side being the diameter of the Earth's orbit, and two measured angles pointing to the star in interest. The problem with this is that the distances are so large that the parallax is tiny. Angles are measured in degrees which are 1/360 of a circle. But this unit is much too large. A degree is composed of 60 smaller units, a "minute of arc". And a minute of arc is likewise made of 60 "seconds of arc". The closest star (after the Sun) has a parallax of just under 1 arc-second. This is an incredibly small angle, about equal to a ping-pong ball at a distance of 5 miles. Even so, the distance to the nearest stars was determined this way.
This technique was first successfully used in 1838 for a faint star known as 61 Cygni. This star that was chosen because it was known to move across the sky indicating that it was nearer than most other stars. But this technique is very difficult to do from the ground. In 1989 the satellite Hipparcos was launched. It provided distances, accurate to better than 10%, for about 30,000 stars within about 300 light-years.
To determine the distance to further objects astronomers needed to find a set of what are called "standard candles". As the name implies, these are objects whose actual brightness is known, so that their distance could be inferred from how bright they appeared to be.
In 1908 Henrietta Swan Leavitt discovered that there were a group of variable stars in a small galaxy that orbits our own Milky Way that had a consistent relationship between their brightness and the period of their variation. The stars, called Cepheid Variables, have a distinctive pattern of brightening quickly and fading more slowly. The important thing about these stars is that since they are all in this nearby galaxy they are all about the same distance from us. There are also cepheid variables much closer to earth and once the distance to them was determined the distance to all the others could be computed. This is the method Edwin Hubble used to find the distance to other galaxies and determine that the universe is expanding. This works for galaxies that are near enough for our telescopes to resolve a single, not too exceptionally bright, star.
For more distant objects another, far brighter, standard candle is used. Every few decades, per galaxy, a star explodes. An exploding star is called a supernova. At peak brightness these explosions can be as bright as the entire host galaxy so they can be seen over truly huge distances. There are only a few different kinds of supernovae and one of them, type Ia, has a uniform peak brightness. This allows us the determine the distance to objects far across the observable universe.
Other techniques are available. See here for more info.