The Hebrew alphabet initially didn't have vowels, so the name was written as YHWH. When vowels were introduced they decided to write the vowels for Adonai above YHWH, to remind readers not to say his name, as it was too holy. Eventually people forgot this logic and assumed it was the normal spelling of his name.