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)