Great Vowel Shift
The change of pronunciation during the GVS affected long stressed vowels. Therefore, “y” in “only” didn’t change pronunciation because it is not stressed. But the same vowel changes pronunciation in the word “my” because it is stressed. The place of pronunciation in the mouth changes, it shifted so that is was pronounced in a higher place in the mouth.