interjection of surprise
哎 represents an interjection of surprise, similar to an exclamation like "ah!" or "oh!" in English. It is a vocal sound made when startled or caught off guard.
哎 is a phono-semantic compound combining 口 (mouth) with 艾, which likely provides the sound. It was created to represent a vocal exclamation of surprise.
The mouth radical 口 on the left shows this is a sound made with the mouth. The right side 艾 looks like a person throwing their hands up in surprise, so together 哎 is the surprised "ah!" you blurt out.
For ガイ, imagine a surprised guy shouting "Guy!" when he sees something shocking: guy -> ガイ, and his mouth 口 forms the exclamation.
—