It was before my time, but I understand that Chinese immigration to California boomed during the Gold Rush of 1852. Like many of the Mexican immigrants coming to the United States today, many of the Chinese immigrants were young men looking for short-term employment who, after completing their work and making some money here, then returned back home to China. They didn't assimilate, they worked for low wages and were accused of driving down the cost of labor, and were suspected of being opium addicts.
In contrast with China, however, the isolationist policies of Imperial Japan thwarted Japanese emigration, and it was not until 1868 that the Japanese government lessened restrictions and Japanese immigration to the United States began. American entrepreneurs were motivated by anti-Chinese sentiment to recruit Japanese laborers over the Chinese. Unlike the Chinese immigrants, most of the Japanese who arrived wanted to permanently reside in the United States and came in family groups. They assimilated to American social norms and clothing styles, and many joined Methodist and Presbyterian churches. They were well received, at least initially, and the U.S.-Japanese Treaty of 1894 guaranteed them the right to immigrate to the United States and to enjoy the same rights in the country as U.S. citizens.
But as the Japanese population in California grew, they began to be viewed by Americans with the same suspicion and hostility as were the Chinese immigrants, and by 1905 anti-Japanese rhetoric filled the pages of the San Francisco Chronicle. A group calling itself the Japanese and Korean Exclusion League was established in San Francisco and petitioned the school board multiple times for segregated schools, but their complaints were dismissed because it was fiscally infeasible to create new, segregated facilities.
However, the Great San Francisco Earthquake of 1906 and the subsequent fires destroyed much of the city, including the schoolhouses, and after the fire, the school board gave in to the Exclusion League and sent all Japanese-American students to the Chinese Primary School, renaming it "The Oriental Public School for Chinese, Japanese, and Koreans."
Japanese-American parents were angered at the idea that their children were forced to receive an education that was not up to par with that of white children. Many Japanese Americans argued with the school board that the segregation of schools went against the Treaty of 1894, which did not expressly address education but did indicate that Japanese in America would receive equal rights.
Tokyo newspapers denounced the segregation as an "insult to their national pride and honor." The Japanese government was highly concerned at that time with their reputation overseas, as they wanted to protect their growing reputation as an emerging world power.
Japan's successful transformation into a modern, military power was first demonstrated by its defeat of China, long the preeminent power in East Asia, during the Sino-Japanese War of 1894-5 over influence in the Korean peninsula. Japan then defeated Russia, a major Western power, in the Russo-Japanese War of 1905-06 over rights in Manchuria and Korea. Chinese reformers and revolutionaries soon based themselves in Japan and Western nations took note of Japan's new military might.
Meanwhile, back at home, U.S. government officials were aware that a civil-rights crisis was brewing in San Francisco that could negatively affect relations with the burgeoning Japanese power. It was against this background of bigotry and anti-immigration sentiment that the United States entered into several agreements and post-war treaties with Japan, recognizing the Japanese claims over the Korean peninsula and parts of Manchuria in an effort to maintain diplomatic peace.
The resulting Japanese colonial rule of Korea was quite harsh. For the first ten years, Japan ruled directly through the military and any Korean dissent was ruthlessly crushed. The Korean language was suppressed and people were forced to assume Japanese names and speak Japanese in public. Still greater controversy involved the use of ‘comfort women.’ Some elderly Koreans today can still remember young girls of middle- and high-school age being taken away and told that they would be working in Japan and getting paid, but in reality were forced into sexual slavery and made to work in factories with no pay. Of the companies still around today, Mitsubishi was one of the most infamous users of Korean and Chinese forced labor. Those who spoke poor Japanese were more likely to be taken away.
In Korea today, there is still great resentment toward Japan over this issue, and towards the United States for its diplomatic role in ceding the Korean Peninsula to the Japanese government. Theodore Roosevelt even won the Nobel Peace Prize for his efforts in moderating the Treaty of Portsmouth that ended the Russo-Japanese war and recognized Japan's sovereignty over the Korean peninsula.
But America's diplomatic hand was forced to a degree by a necessity to placate Japanese anger over the treatment of immigrants and the segregation by the San Francisco School District. If it wasn't for the actions of racist, bigoted groups like the Japanese and Korean Exclusion League, Roosevelt might not have had to concede to so many of Japan's imperialistic demands, and the rape of Korea may not have occurred, or at least not for the duration and with the impunity for which it did.
Today, a paranoid madman is in control of North Korea. The madman has nuclear weapons - not good ones to be sure, but nukes all the same. He can successfully manipulate his long-suffering people with apocalyptic promises of revenge and annihilation of Japan and the United States due to the brutal treatment they received. And that brutal treatment was a result, even if indirectly, of the anti-immigration frenzy stoked by the San Francisco Chronicle and racist hate groups.
Presidential candidates today can talk tough and say ugly things about Mexican and Islamic immigrants, and possibly even ride popular opinion and fear to the tops of the polls, but looking at the way that karma came back at us when we tried this in the past, you have to question how good of an idea that really is.
My sources of information for this post include an eye-opening article titled My Korean Grandmother’s Memories of the Japanese Occupation and the Korean War by Christopher Smith at Asia Pundits; the U.S. Department of State, Office of the Historian's Milestones 1899-1913; Columbia University's Asia for Educator's Central Themes and Key Points; and of course, the indefatigable Wikipedia. If I've got anything here incorrect, please instruct and enlighten me, as much of this history is news to me.