The greeting evolved from the commoners’ greeting (said to lords) servus humillimus (Domine spectabilis), meaning your humble servant, my noble Lord. No subservience is implied in modern use. Compare Slovak servus, Romanian servus, German servus, Swedish tjenare.
Use it for both hello and goodbye to a single person but only if you could also use the informal te during conversation. When greeting a group of people, use szervusztok. Szervusz is more formal and polite than its colloquial variant szia. It sounds even more polite if the person's name is added: Szervusz, Júlia! - Hello, Julia!