Good question! The principle is rather simple, but the devil is in the details. I’ll leave out the details and let you know a way to get a reasonable guess at the age of the universe.
Have you heard of Hubble? Like the Hubble Space Telescope? Well Edwin Hubble was the father of modern ‘cosmology’ (the science of galaxies and the universe as a whole). Hubble discovered that galaxies far away are moving away from us and, moreover, the galaxies furthest away are receding the fastest! If you measure the distance and speed of distant galaxies and plot them on a graph, you’ll find it makes a nice straight line with a slope called Hubble’s Constant. If you do 1 divided by the Hubble Constant, it gives you a number of 14 billion years: approximately the age of the universe!
As I say: very simple. The trick is getting good measurements of galaxy distances and speeds 😉