To embalm a body is, word for word, to put balm in it. The word is a recipe.
The verb came into English in the 14th century. Merriam-Webster traces it through Middle English embaumen to Anglo-French enbaumer or enbasmer, formed from en-, "in," and basme, "balm." Dictionary.com dates it to between 1300 and 1350 and gives the Old French as embausmer. Middle English writers spelled it both embaumen and embalmen.
The balm goes back much further. Basme descends from Latin balsamum and Greek balsamon. Merriam-Webster calls the Greek word probably Semitic in origin and akin to Hebrew bāshām, "balsam." A balsam is an aromatic, usually oily and resinous substance that flows from certain plants. Such resins were valued for their scent and as medicine.
The best-known embalmers worked long before the word existed. In ancient Egypt, the Australian Museum explains, the body was first dried with natron, a salt collected at the edges of desert lakes. After 40 days the natron was removed and the body cavities were packed with linen, herbs and other material. The skin and first layers of linen wrapping were coated with resin. The whole process took about 70 days. The most elaborate version was reserved for royals and high officials, roughly between 1550 and 664 BCE.
The English word kept the idea of fragrance alongside preservation. Merriam-Webster lists a second literal sense, to fill something with a pleasant scent. It also records figurative ones: to protect something from decay or oblivion, as in "embalm a hero's memory," and to fix something in a static condition. Dictionary.com has a poetic sense too, to give a sweet fragrance to.
So the word moved from a sweet-smelling resin, to the act of anointing the dead, to a way of keeping memories from fading.