At the Cairo conference, there was a general agreement among the Allies about the concept of an indpendent Korea after the defeat of Japan. However, the exact terms of occupation and independence weren't agree upon at the time. Some in the State Department wanted co-rule between the Soviets and the Americans. However, most realized that having a joint occupation zone would be unworkable.
Ultiamtely no formal arrangement was reached and instead both sides created facts on the ground during the final stages of the war (i.e. August 1945). The Soviets conquered northern Korea during the Soviet invasion of Japanese occupied Manchuria and Korea. As soon as Japan capitulated, the US, fearing a completely Soviet Peninsula petitioned Nat. China to occup Pusan. The ROC, hardly in a condition to engage in a foregin occupation declined. The United States then unilateraly declared that the area south of the 38th parrarllel (essentially all of Korea not already overrun by the Red Army) to be "part of Japan and thus under the exclusive occupation of the United States," effectively sealing the Soviets out of that area.
The Soviets accepted this arrangement because they were confident that a.) the communists would win the first pan-Korean election, or b.) that the United States would soon withdraw from South Korea, thus leaving the area open for invasion. The United Nations soon formalized the de-facto partition and drew up a plan for democratic pan-Korean elections supervised by the UN. The Soviets, no longer confident that the communists would win, refused to permit this election to occur in their zone of occupation, instead opting to hold their own "unbiased" election. The US agreed to this election, and the government of the Republic of Korea was thus born.
https://en.wikipedia.org/wiki/South_Korean_presidential_election,_1948
More information:
https://en.wikipedia.org/wiki/Korean_independence_movement
https://en.wikipedia.org/wiki/Division_of_Korea