In some important ways, North Korea's hostile and suspicious attitude toward the outside world is a continuation of Korea's long tradition of isolation, seclusion, and defensiveness against external threats.
For centuries, Korea fiercely maintained its independence and cultural identity against more powerful neighbors, especially China and later Japan. After devastating invasions from Japan at the end of the 16th century, Korea became extremely isolated, allowing few foreigners to enter Korea and even fewer Koreans to leave. Korea's official contact with the outside world was confined to three or four diplomatic exchanges a year with China and very limited trade with Japanese merchants. There were no significant numbers of Westerners living in Korea until the end of the 19th century. Korea was even more secluded than Japan, and Europeans and Americans who encountered Korean resistance to foreign influences in the 19th century nicknamed the country the "Hermit Kingdom."
When Korea was finally opened up in the late 19th century, the country became the object of new geopolitical struggles, and the site of two wars: between China and the rising Japanese empire (1894-5), and between Japan and Russia (1904-5). Japan won both those wars, and in 1910, Korea became a colony of Japan.
The Japanese colonial period (1910-1945) was a brutal experience for most Koreans. Thousands of Koreans died fighting against Japanese colonial rule. Hundreds of thousands were recruited for forced labor in Japanese industries and sexual servitude to Japanese soldiers during World War II. The Japanese colonial state was a harsh, highly militarized regime. The Japanese did modernize Korea to some extent, and began to industrialize the northern part of the country in the 1930s, but Japanese colonial rule did not teach Koreans anything about liberal democracy or how to build a free society. Thus, Japanese colonialism was another authoritarian layer of experience, on top of Korean tradition, that has influenced present-day North Korea.
Then, immediately after the end of colonial rule, North Korea underwent a Stalinist revolution under Soviet occupation between 1945 and 1948. The Soviet Union was also a closed, isolated, suspicious society. Thus, North Korea is the heir to these three illiberal systems -- Korean monarchy, Japanese colonialism, and Soviet communism -- and has had virtually no exposure to Western liberal influences.
Finally, Kim Il Sung and other early leaders of the North Korean regime were guerilla soldiers fighting the Japanese in Manchuria in the 1930s and early 1940s. These people were a group of determined fighters who had little formal education and almost no exposure to the world outside of Korea, Manchuria, and the Russian Far East. Given these experiences and traditions, it is no surprise that North Korea is authoritarian, isolated, and suspicious of the outside world.
The Korean War reinforced North Korea's sense of its vulnerability and its hostile attitude toward the United States. North Korea was utterly devastated by American bombing. Every major city was flattened; in the capital, Pyongyang, only one building was left standing at the end of the war. As many as two million North Koreans -- 20 percent of the population -- died in the war. During the war most North Korean citizens were forced to live underground to escape the bombing. The North Koreans also feared that the U.S. would use nuclear weapons against it, and the U.S. considered dropping atomic bombs on North Korea in the spring of 1951.
North Koreans have long felt threatened by American nuclear weapons, and sought protection under the Soviet nuclear umbrella by signing a mutual defense treaty with the USSR in 1961. But North Korea does not have a lot of trust in Russia or China either. The Russians did not help North Korea during the Korean War as directly as the North Koreans would have liked, and although China sacrificed a great deal in the war, North Koreans have traditionally been concerned about China's own ambitions to dominate the Korean peninsula. In the early 1990s, both China and Russia stopped giving North Korea oil at subsidized prizes, which badly hurt the North Korean economy. The Russians have abrogated their 1961 defense treaty with North Korea, and although the China-North Korea treaty is still presumably in effect, it is not clear whether China would really aid North Korea in case of an attack.
For many years North Korea has also felt deeply threatened by South Korea, which has a much larger population, a much more developed economy and a much more modern army than the North. South Korea is also backed by the United States, as is Japan, Korea's historical enemy. From North Korea's perspective, it is surrounded by enemies or, at best, untrustworthy "friends". This has reinforced North Korea's attitude of self-reliance or Juche. It may also be a reason that North Korea feels possessing nuclear weapons is the best way for it to defend itself.
North Korea was ruled by Kim Il Sung from the time the regime was founded in 1948 until his death in 1994, and has since been ruled by Kim's eldest son, Kim Jong Il. These are the only leaders most North Koreans alive today have ever known. The veneration of Kim Il Sung, which began in the 1940s and has grown ever since, exceeds the "cults of personality" promoted by Stalin, Mao, and perhaps any other modern leader. Kim was certainly influenced by both Stalin and Mao, but his own cult is also reminiscent of Japanese emperor-worship (something Kim saw often while growing up) and traditional Korean ancestor-worship. Elements of Korean folk religion, and even Christianity, appear to influence Kim's propaganda cult. North Korea, especially the area around Pyongyang, was the center of Protestant Christianity in Korea before the Korean War. Kim Il Sung himself grew up in a Christian household, and in a strange way the religiosity of North Koreans and even Kim himself may have contributed to the quasi-religious aura of his personality cult.
Kim was a genuine anti-Japanese hero before 1945, but by the 1960s the North Korean propaganda machine had made him almost into a god. It appears that most ordinary people in North Korea revere the two Kims as great heroes and leaders. They have no outside point of reference from which to criticize their leadership, and have never seen any alternative. North Korea is a highly stratified society, with a small elite (mostly in Pyongyang) who have many privileges, but the vast majority of North Koreans living a bare, impoverished existence. Since the late 1960s, after Kim was able to eliminate (often through purges and executions) all his potential rivals, North Korea has been a kind of family-state, ruled by Kim's close relatives and his former comrades from his Manchurian guerrilla days. As the elder Kim and his cohort began to die off in the 1990s, more of the top elite have been Kim Jong Il's generation, but the Kim family is still very much at the apex of power.
North Korea is a society with a permanent siege mentality. It has lived under a constant threat of war since the 1950s. State propaganda continuously reinforces the threat of attack from the Americans and the danger of revived Japanese militarism. This modern state of insecurity is built upon an older history of colonialism and traditional isolation to create an attitude of profound suspicion of the outside world. The collapse of the Soviet Union and other communist states made North Korea even more isolated, and also contributed to economic disaster and famine in the 1990s.
But despite its grave difficulties, North Korea is still a tightly controlled society with a strong sense of its right to self-defense. Up to now, thanks in part to the careful control of information in and out of North Korea, there has been little if any sign of internal dissent. There is no reason to doubt that North Korea, if attacked, would fight back with fierce determination.