Magnetic helicity evolution during the solar activity cycle: Observations and dynamo theory