Well, some languages do, some don't. Some specific greetings do, some don't. A bit of sampling of the omniglot collection of greetings, with the help of the indispensable wiktionary for the translations and etymologies, shows a number of other commonly encountered components; some greetings contain references to the recipient (such as a personal pronoun), the equivalent of "good", or references to body movements such as one might imagine having been used as a greeting visible from a distance (bowing). Swahili has "habari" which roughly means "News?" or more loosely translated as "How are you?". Some other greetings seem to have interjectional (or possibly just lost) origin. Every language has a range of different greetings tailored for different social situations.
Greetings, however, do not fully mean all those things. Greetings are speech acts aimed at advertising presence, relationship and status. In prehistoric times, people (especially strangers) used to be eminently dangerous to other people, and vice versa. Striking preemptively during a one sided unplanned encounter before it becomes a mutual encounter was a thing. Greetings may have been invented as a form of communicating "I'm here, but I mean no harm to you"; or "My palms are empty, my weapons are limited"; or the more recent, because more distinctly human, "If you can understand my greeting, we are related to each other even if we haven't met before". I suppose that such early greetings could have worked best over more than the shooting distance and not necessarily be vocal or fully grammatical even when used by humans.
The oldest recorded greeting I'm aware of is Sumerian "silim" - it's oldest just because of the essentially random point where the recorded history emerged from unrecorded prehistory, but I like analyzing it explicitly anyway because you can either say it means (something like) "health" in Sumerian, or you can say that it's borrowed from Akkadian "šalim" meaning "peace". (The latter Semitic root has been borrowed into a number of other non-Semitic languages over the subsequent millenia, which partly answers your question.)
What do "health" and "peace" have in common? Well, obviously, "I wish you well", or originally perhaps "I wish you no harm". It is implicit (and often explicit) that the health or peace is being wished to the recipient of the greeting. The speaker is trying to send a strong signal that the encounter will not leave the recipient mutilated or running for their life: and this may perhaps be somewhat conditional on the recipient replying to the greeting promptly and conventionally.
More refined social hierarchy can lead to more refined greetings and new greetings can start evolving from other speech acts or from other language expressions; those will typically exist side by side with more basic greetings usable toward a complete stranger.