Effect of hydrogen on magnetic properties in MgO studied by first-principles calculations and experiments