Ya, if you dont save how much was removed, and the base health changes between equipping and unequipping, then you'll end up messing stuff up. Also just so you know, if your health changes while your wearing your ring, with that script, it wont change how much health is turned into magicka.
Ex.
You have 100 health and 100 magicka
You put on ring, your stats change to 50hp and 150 magicka
You level up and choose health
You now would have 110hp and 100 magicka if the ring wasnt on which would be 55/155 if you put the ring on then
But with that code, until you remove the ring and re-equip it you'll have 60 health and 150 magicka