Cepheid variables were our first standard candles - phenomena that allow us to reliably determine galactic and extragalactic distances.
These stars brighten and dim with a regular period that correlates with their maximum brightness. Measure the former and you know the latter. Compare that brightness, inferred from period, with how bright they appear to be, and you how far away they are.
Basically, a light bulb looks dimmer from further away. Quantify that and you can judge the distance.