The co-evolution of life and the nitrogen cycle on the early Earth