The ogre's name is a warning label. In Yiddish, shrek means fear or fright.
William Steig used it for the hero of Shrek!, a picture book published on 17 October 1990. Steig had spent decades as a New Yorker cartoonist, from 1930 into the 1960s, drawing more than 1,600 cartoons. He began writing children's books at 61. By the time he wrote Shrek! he was in his eighties.
Wikipedia describes the name as a romanization of the Yiddish word for "fear" or "fright," related to the German Schreck. The Duden dictionary traces German Schreck through Early New High German to Middle High German schrecke, from the verb schrecken. The Yiddish word, Moment Magazine notes, entered the language from German.
Moment adds some texture. Yiddish speakers most often use the word as an adjective, shreklekh, as in shreklekh zach, "a terrible thing." A scarecrow is a shrek foygl. Yet the word is missing from Leo Rosten's 1971 classic, The Joys of Yiddish, and from its sequels.
Steig was born in New York in 1907 to Eastern European Jewish immigrants. Moment quotes Aaron Lansky of the National Yiddish Book Center. He thinks Steig made the word sound playful while giving the ogre a Jewish quality, as the outsider everyone fears. The name delivers that idea in one syllable, while sounding light enough for a children's book.
The film version took years. Steven Spielberg bought the rights in 1991. DreamWorks later acquired them for about $500,000, began serious development in November 1995, and released Shrek on 18 May 2001.
The same German word had already given horror a famous name. Max Schreck played the vampire Count Orlok in Nosferatu in 1922. The BFI notes that his surname means roughly "shock" or "terror."
The film made the name so familiar that its meaning disappeared. For most English speakers, Shrek now means a large green ogre. In the language it came from, it still means fright.