as a question adverb (introducing a direct or indirect question): Why didn’t you phone me? ♦ I know why he’s worried. (followed by an infinitive without ‘to’): ♦ We can start now, so why wait?
as a relative adverb (referring back to a noun and introducing a relative clause): She’s tired and that’s the reason why she’s so bad-tempered. (introducing a clause that is the subject, object, or complement of another clause): ♦ Everyone in Dublin is so friendly, and that is why I love the city.