Pronounced ài (fourth tone), 唉 expresses sadness or regret. Pronounced āi (first tone), it is a casual 'yeah' or grunt of agreement and recognition. Same character, the tone carries the mood.
mistakes
Don't confuse 唉 (a melancholy sigh) with 哎 (a sharp 'hey!' to get attention). 唉 looks back with regret; 哎 calls out.
Left mouth radical, the indexing radical. Marks the character as a vocal sound rather than a meaning-bearing word. Same role as in 哎, 嗯, 嘿, all interjections where 口 simply tells the reader this is something coming out of the mouth.
Right phonetic 矣 supplies the sound (yǐ to āi or ài, with a vowel shift). It is itself a classical sentence-final particle marking completion. The pairing fits: a mouth over a 'so it ends' particle gives 唉 its tone of resigned sigh.