Measurement of the Crab Nebula spectrum over three decades in energy with the MAGIC telescopes