The first of two letters now written ㅇ, a simple circle, was a 'zero' symbol invented by King Sejong to hold the place of a consonant in a vowel-initial syllable. The traditional account* holds that its form is the outline of the throat, 喉形, which is visible when pronouncing vowels.
Gari Ledyard proposes that the other letter now written ㅇ, ㆁ, which had the velar nasal value [ŋ], was a conflation of the zero ㅇ and the vertical stroke comprising the lower part of the velar plosive ㄱg (see the similar derivation of the alveolar nasal ㄴn from the lower part of the alveolar plosive ㄷd, and of the labial nasal ㅁm from the lower part of the labial plosive ㅂb). This not only made the hangul ng more robust graphically than a simple stroke, which could have been confused with the vowels, but iconically represented its dual sound values in initial position, ng in some Chinese dialects, silent in others, and silent in Chinese words borrowed into Korean.
When hangul was revived in the 20th century, and it was no longer a concern to accurately transcribe Classical Chinese phonology, there was no longer any possibility of confusing the two ㅇ letters, and they merged.
* Hunmin Jeongeum Haerye “Explanations and Examples of the Proper Sounds for the Instruction of the People” (1446), defining and explaining the script now known as 한글(han-geul, “Great script, Korean script”) in South Korea and 조선글(joseon-geul, “Korean script”) in North Korea.