Hungry? Just grab a tray and chow down on a carton of chocolate milk, a sloppy joe, and some green beans. It’s a ritual shared by millions of American schoolchildren each year in cafeterias around the country. But though the words "school" and "lunch" seem to go together like peanut butter and jelly, the phenomenon has only really been around since the late 19th century.

School lunch has its roots in Germany, where as early as 1790, an American-born man known as Count Rumford began mass feedings for poor kids who worked part-time in exchange for schooling and food. (Rumford had fled the United States during the Revolutionary War because he supported King George.) The soup that Rumford served was made from super-cheap ingredients—think barley, potatoes, and sour beer—and was the beginning of the soup kitchen as we know it.

But the idea of feeding kids at school never really caught on in the early U.S. Instead, kids were expected to bring their own food to school or head home to eat. That was a problem for some: In the United States, poverty accompanied the huge waves of immigrants who flooded the nation during the 19th century. By the 1870s, an estimated 12 percent of school-age children in New York City were homeless, and those who did have homes were often shoved into filthy tenements. Child poverty became a scourge, and as child labor laws were tightened, more children would flood into the nation’s schools, often without enough to eat.

Poverty finally became a national issue when a sociologist named Robert Hunter published a groundbreaking book in 1904. Appropriately titled Poverty, the book described the conditions endured by working-class people in Chicago and New York. Galvanized by his descriptions of poor families and children, many of them immigrants, Progressive-Era reformers began to brainstorm ways to get kids the resources they needed. This was serious business: In a 1903 article in The School Journal, an anonymous author wrote that healthy school lunches were nothing less than a chance to improve "the physical vigor of the urban population." Earlier small-scale programs in cities like Boston and Philadelphia had shown that school lunches could have great effect.

Help for kids finally arrived in the form of public-private partnerships between social workers, charitable institutions, and schools themselves. For example, the Women's Educational and Industrial Union provided hot lunches throughout Boston at the turn of the 20th century to an average of 5500 students each day. Their 1913 annual report describes sample menus including beef and barley soup, celery and nut salad, creamed eggs, and orange marmalade or jam sandwiches.

Soon, “school feeding,” as it was then called, began in earnest. Most school lunch programs were initially offered by charitable organizations, but school districts themselves quickly realized that when kids had food, they were more likely to stay in school and perform well in class. Lunchrooms and cheap lunches became a school staple.

But school lunch was more than a hot meal—it was a chance to educate immigrant children on how real Americans ate. According to one 2003 book, early advocates hoped that school cafeterias would “persuade children to abandon the diet of their parents for a new American cuisine.” Classrooms had civic classes; cafeterias had “American” foods with fewer spices and plenty of milk. As more and more kids began to rely on school lunch, especially during the Great Depression, menus became a way to unify future generations of Americans.

Eventually, school lunch became seen as a way to “eat democracy”—a democracy that involved scarfing down USDA-supplied surplus foods like dairy products and wheat. (When the USDA took over administration from the War Food Administration, 60,000 schools in 20 states received shipments of donated food.) As John Vysnauskas, a priest who taught at Holy Cross in Chicago, told the Congressional Subcommittee on Appropriations in 1947: "In our schools, we have no longer children of merely Lithuanian descent. They are pure Americans. There is no language but the English language used in these schools. ... Our children eat democracy and have learned to associate in a democratic way with children from … other schools."

In 1946, this lunchroom democracy became the law of the land when the National School Lunch Act was approved. The program made school lunch a permanent fixture in American schools. Today, the Act offers free and reduced-price lunch and milk (and even breakfasts in some cases) to more than 31 million kids nationally. In 2010, the Healthy Hunger-Free Kids Act updated the school lunch program for the first time in more than 30 years to make sure menu options are in line with current nutritional guidance, with an emphasis on whole grains, fruits, vegetables, and protein. (Forget those white-bread sandwiches: The new rules stipulate that grain items must include 50 percent or more whole grains by weight or have whole grains as the first ingredient.)

These days, school lunches still act as an arbiter of kids' tastes. But mystery meat and bland, Americanized food is becoming more and more unusual as school districts embrace diverse palates. Things like salad bars and ethnic cuisine options are increasingly making the hot lunch of yore seem all but obsolete. Still, the concept of school lunch remains—an institution as American as apple pie (and, in some cases, almost as delicious).