The far eastern peninsula of Korea had long been a prize dominated first by China and then by Japan. There was hardly any time in recent history when the Koreans ruled themselves.
During World War II, the Allies met to decide who would control Japan's territories after the war. In 1943 at the Cairo Declaration, the intention was made for Korea to be free and independent. It didn't work out that way.
After Japan surrendered, Korea was occupied by the U.S.S.R. in the North and the United States in the South. The dividing line was the 38th parallel.
The Russians wasted no time in setting up a well-armed communist government. In the South, the Americans tried to set up a democracy. The situation was not working well.
The Russians suggested that the super powers leave and let the Koreans sort themselves out. The Americans knew that North Korea would walk all over the southern half of the country. The United Nations was called in.