Why are there so many ways to "hello" and "good-bye" in Korean?
I think the main reason is that we use 반말 or 존댓말 depends on the listener. 반말 is completely informal. You can say this only for your friends with same or younger age. You can say simply ‘안녕’ for them.
On the contrary, you should use 존댓말 for your your elder or boss, most of the stranger, or in public. Among 존댓말, we have two version of more and less formal language. If you say 안녕하십니까, it is the most polite way to say hello. If you want to show your affinity but still courteous, you can say “안녕하세요.”. Now, when you want to say good-bye, you can say 안녕히 계세요, 안녕히 가세요, 잘 있어, 잘가, or 안녕. Since the meaning of ‘계세요’ is ‘you stay here., you can say 안녕히계세요 to somebody who is going to stay the location you have met, for example, a store manager you have visited or the host who invited you to their home. Meanwhile, ‘안녕히가세요’ means, ‘you go well.’ So, 잘 가, or 안녕히 가세요 is for the somebody who is going to move to another location from where you have met. 안녕, and 잘있어 are 반말, and they mean be good, take care, or good-bye. You can use any of them. 안녕 can be used for both saying hello and good-bye. 잘 자, and 안녕히 주무세요. is just sleep well and good night. 잘 자 is 반말, 안녕히 주무세요 is 존댓말. That’s all.