The character 韓 for the name of Korea was arbitrarily chosen for its sound, coincidentally being the same character of some ancient Chinese states.
The first thing to point out is that there is rarely any Chinese character that was invented solely as a name for a people. Among the historical Chinese-character using countries and regions, their earliest recorded names are:
The earliest name among ancient states that are now considered Korean is "Joseon" (조선), written as 朝鮮, and has been used for the majority of unified Korean history as the name of Korea; significantly, it is the name of the state of Gojoseon, the Joseon dynasty, and the current official name of North Korea, 朝鮮民主主義人民共和國. The name 조선 is of uncertain origin (some speculations are given here), but the characters definitely referred to other concepts first:
朝 (
) originally depicted the sun 日 rising through trees (木 or 屮) and meeting the moon (月) in the sky, indicating the meaning dawn/morning.
鮮 (
) was originally a graphical merger of sheep (羊) and fish (魚). Shuowen Jiezi explains it as "the name of a fish from 貉國 (a state in Northeastern China)" (鮮,魚名,出貉國。从魚,羴省聲。
, thus a semanto-phonetic compound comprised of semantic 魚 and phonetic reduced from 羴).
"Han" (한) as a name of Korea was first attested as the three confederacies of Samhan, formed after Gojoseon's demise. It is a native Korean morpheme originally meaning great, speculated to be related to Turkic khan (as in Genghis Khan), and was variously written phonetically with 韓, 幹, 刊, 干, and even 漢. The name had nothing to do with various ancient Chinese states named 韓 or 漢.
韓 was originally
(
). Shuowen Jiezi glosses it with the meaning fence surrounding a water well, and explains it as a semanto-phonetic compound comprised of the phonetic 倝 and semantic 韋, where 韋 means 'to surround' and is now written 圍 (as in 圍棋, the Chinese name for the board game 바둑). For reference, 韋 (
) originally depicted patrolling (feet
,
) around the outside of a city wall (wall 囗).
한국
asKorea
originates from 고려 (Goryeo) which was propagated by foreign merchants visiting Korea during 918년~ 1392년.