The words gum meaning "flesh around the teeth" and "sticky thing you chew" are not related. The former, through Middle English gome, comes from the Old English word for "palate", goma, which eventually traces to Proto-Germanic gaumo and Proto-Indo-European ghumo. The other kind of gum you get from a plant has a much more interesting origin. It was borrowed from an Anglo-Norman word also spelled gome, which derives from a Latin word spelled either as cummi or gummi. That in turn goes back to Ancient Greek kommi, still referring to the plant product, and ultimately is thought to be from the Egyptian word qmy, meaning "anointing oil". This obviously shifted in definition as the resin was traded around the Mediterranean and very likely hails from a Proto-Semitic root.
Adam Aleksic, a rising sophomore studying linguistics and government at Harvard University, has been described as the internet's sixth most famous etymologist. He also has disturbing interests in politics, vexillology, geography, board games, conlanging, and law.