Magnetic fields are ubiquitous in astrophysics, but their dynamics and origin are controversial. I will discuss recent developments in dynamo theory, the origin of galactic magnetic fields, and the implications of this work for observations of the early universe.