1. What puzzled me is why he left the country.

2. What puzzled me is the way why he left the country.

3. What puzzled me is the way he left the country.
=================
Are they all the same?
What is the part of speech of 'why' in #1?

1 and 3 are okay. 2 is not.

In 1, 'why' is an interrogative pronoun, introducing the indirect question there.