Korea was two separate countries when the war began (North Korea and South Korea). After the Japanese left after WWII, the USSR and the USA, had their influences over Korea (communist=USSR & democracy=USA) which resulted in the 38th parallel which was the division of Korea into North Korea and South Korea. When the USSR left North Korea and the USA left South Korea, the North Korean leader (Kim Il-Sung) wanted to reunify Korea as a communist state.
The war of Korea was a result of two different ideologies between the two main leaders (Kim Il-Sung & Syngman Rhee) at the time of how Korea should be ruled. One wanted communism where the other wanted to remain a democracy.
The war began when North Korea invaded South Korea on June 25th, 1950 to reunify Korea as a communist state. South Korea received help from the US and the UN. When the UN troops were ordered to push the North Korean soldiers further beyond the 38th parallel, the Chinese government had intervened as they reached the Yalu river which borders North Korea and China. North Korea then received help from their communist ally and support from the USSR. The communist forces pushed the UN and South Korean troops back to the 38th parallel where they had been a static (means both sides continued to fight and neither side were advancing) war for a period of time until an armistice was signed on June 27, 1953.