The Hunmin Jeongeum Haerye, the treatise introducing the principles behind the Korean alphabet written by its inventor King Sejong in 1446, explains that this glyph was derived from the outline of the mouth because /m/ is a "labial sound" (唇音). Note that it is nearly identical in shape to 口, the Chinese logogram for "mouth". According to Sejong, the letters ㅂ (b, “b”) and ㅍ (p, “p”) were created by adding strokes to ㅁ, because all three are bilabial sounds.
Gari Ledyard proposes that Sejong derived ㅁ from the lower part of ㅂ, which he believes was itself inspired by the 'Phags-pa letterꡎ(p) turned around. Ledyard gives evidence that Sejong was inspired by 'Phags-pa for the basic glyph forms, although he changed the shapes of the letters drastically in order to enhance the simplicity and rationality of his script, and the ultimate shape of the letters may indeed have been influenced by that of the speech organs (Ledyard 1997).