Before the letter W was invented, the rune wynn was borrowed into the Latin AngloSaxon alphabet as a way of representing the /w/ sound. The letter yogh evolved out of Insular G, an Irish variation of the traditional letter G. The phonetic value of yogh varied. It could represent the /y/ sound, the guttural /x/ sound as in the Scottish "loch," and others. Many Modern English words spelled with GH digraph (laugh, though, night, etc.) were once spelled with the letter yogh.
Interested in taking part in our virtual Latin 101 course this summer taught by Harvard PhD candidate Rebecca Deitsch? Learn more here: https://www.wordsforgranted.com/latin-course