The only free and comprehensive online etymological dictionary of the Spanish language
guay (Interjection) "woe!;" (Spain) "great!"
13th cent. There are three origin theories of this word. If a majority of linguists is to be taken as some sort of consensus, then guay is probably from Latin "woe." Alternatively, the word is from Gothic wai "woe." From Proto-Germanic *wai 'id.' Both Latin and Proto-Germanic *wai trace back to Proto-Indo-European *u̯ai̯ 'id.' A third idea is that the word is from Andalusian Arabic *way. See Dworkin (2012) for further discussion.
Variants
Old Spanish guayar "to wail," guaya "wailing"
Indo-European
Romance
Italian guai, Romanian çai
Celtic
Old Irish fáe "alas," Middle Welsh gwae 'id.,' Middle Breton goa'id.'
Germanic
Old Norse vei "woe," Old High German "woe," Old Saxon 'id.,' Old English (English woe)
Balto-Slavic
Latvian vai
Armenian
Armenian vay
Indo-Iranian
Avestan vaii-ōi (?)

The Spanish sense of "great" is a secondary formation through meaning reversal.