The Korean War was a proxy war between the US and the USSR during the Cold War. The Cold War was full of conflicts quite similar to these, with the idea that to win the public over (Capitalism vs Communism), we would have to prove it through war. Conceding Korea to the USSR would give a lot of territory to our opponents, and winning this war would win the public over.
The cold war was a battle of capitalism vs communism. The idea that one idea was better than the other is what caused conflicts like these. The US wanted to contain communism and spread capitalism. If Korea were to fall to communism as China already had, who is to say the whole world wouldn't as well? This is the domino effect, and the main goal of this war was preventing it.
After WWll during the Potsdam Conference In December 1945, formally Japanese-occupied Korea was split in half via the 38th longitude parallel. The north half of Korea was supported by the Soviet Union and the south was supported by the United States. Both sides believed they should have control over the other half. This caused tensions to rise between the two countries along with tensions between the US and USSR fueled by the Cold War. North Korean leader Kim Il Sung declared war on South Korea and invaded sending troops past the 38th parallel on June 25, 1950 ("Millett").
On July 25, 1950, North Korea invaded South Korea, pushing their forces to the far southeast corner. The UN quickly responded by sending troops over from the US via UN Resolution 83 ("Korean War"). Led by General MacArthur, US troops landed behind enemy lines in Incheon and quickly repelled North Korean forces past the 38th parallel, which caused North Korea to send a plea for direct aid to China. Chinese forces responded with an explosive offensive, driving back UN troops to the 38th parallel ("Korean War").
The war settled into a stalemate at the end of 1951, although continuous bombing of the North only ceased in 1953, once officials finished discussing terms at Panmunjom. Even though the talk ended with a ceasefire between the two countries, the war is technically not over. However, there hasn't been any major fighting since then ("Korean War"). That being said North Korea because of the war underwent heavy bombing and economic hardships. The US bombing runs on North Korea were extremely effective as the industrial production of the country was reduced by 60%, and the agricultural output was reduced by 78%. (Young) Those reductions in production prevented the North from recovering from the war the way the South did and the effects of the war can still be felt in North Korea today.