Actually, the full story is this :
During the Korean war, American soldiers, at least the blonde ones, were chased around by groups of Korean children shouting 'mi-guk! mi-guk(in)!'. juliet is partly correct, in that 'han-guk' is an adjective meaning 'Korea' in Korean itself, but the particle 'in' means person. The word 'mi-guk in' actually means 'beautiful person', literally, and is the word used by Koreans to this day to refer to Americans.
Of course, what the soldiers heard was 'Me..gook' - i.e. 'I am a gook' - and so they started using the sound 'gook' to refer to Koreans, and later all Asians, in an insulting and derogatory way.
How ironic is that huh?
Of course, this may be apocryphal, but hey I lived there for a coupla years, and this is the most convincing etymology I could find. Should be true, if it isn't.