Kraut, in the United States, isn’t a very nice word. Dating back to the nineteenth century, the stereotype of the sauerkraut-eating German immigrant was already a thing, and showed up in all the usual places — anecdotes in newspapers, on the minstrel stage, etc. — where one might expect humor at the expense of some racial or ethnic group or another.
During World War I, Kraut became a metonym for German, German became synonymous with wicked, and it became acceptable to use the term as a sneer or a snub, as a way of stirring up enmity and making school-children whose parents derived from Deutchland feel lousy about themselves and about their national heritage.