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) and ㅍ (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).
This suffix is the most common Middle Korean nominalizer in the consecutive gugyeol sources of the fourteenth century and in the Hangul sources of the fifteenth and sixteenth centuries, but is very rarely attested in pre-fourteenth sources. Choe 2017 comments that no intermediary stage appears to exist, and that this sudden post-fourteenth-century dominance of a largely novel grammatical suffix is puzzling and difficult to explain.
The older nominalizers were realis隱(*-n) and irrealis 尸(*-l), both of which are now adnominal suffixes.