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 by adding a stroke to ㄱ (g) to represent aspiration.
In contemporary Korean, when ㅋ (k) is placed on the side, it curves as in the example of 키 (ki), 케찹 (kechap). However, when ㅋ (k) is placed on top or bottom, it retains its original look, as in the examples of 코 (ko), 콩 (kong), 코카콜라 (kokakolla), 녘 (nyeok). This was done in the modern era to make the character look more balanced. This rule is also applied to ㄱ (g).
Because the letter k repeated sounds like a person laughing, putting ㅋ (k) in a consecutive manner stands for laughing in the Korean Internet media. Cognate with Португалскиkkk.