For centuries, astronomers have studied light from distant stars and galaxies to understand how the cosmos works.