The history behind it is that during the Korean war, an American approached a Korean.
The Korean did not understand the American, instead he pointed at him and called out "Mi Gook" which means "America" in Korean. The American then mistakened the Korean and thought the Korean was refering to himself as a "gook." After the Korean War, American started to refer to Koreans as Gooks for short term thinking it was a short name for Korean.
There are many different stories where "gook" came from such as korean foods or HanGOOK.
Person:I hate gook (korean term for soup)
Asian: I luv gook
Person 1: Wut u lookin at gook? You want some fried rice?
Asian: WTF!!! Do you wanna die?
"Hey man, i got new neighbors... Its a bunch of fuckin' Gooks... damn bastards cant drive for shit!" (modern context)
Gook also is at times referred to Korean people.
John McCain: 'I hate them gooks!'
Vietnamese person: 'I may be a gook but I beat the living shit out of you'
U.S. Army: You'll kill 10 gooks for every nigger that dies in battle, but they'll keep on coming.
Gooks are excellent soldiers if you provide them with an AK-47 and white rice.