안녕하세요 was originally a question asking "Are you doing well", "Are you at peace?", or "Are you living well?", but since it is a very common expression, people began to not expect any special answers in reply.
It is better to use polite/formal language because if you use casual/intimate/formal language in a situation where you should use polite/formal language, you might get into trouble.