This is an image we might particularly associate with the United States in the 1950s, when schoolchildren were taught to duck and cover in the event of the flash of an atomic blast. But its use in civil defence drills predates the Cold War (albeit without a Bert the Turtle to help kids remember the message). I've seen scattered references to it being used in ARP drills in British schools in the the 1930s, and the same thing may well have happened in the First World War. But details, and photos, seem to be rare. The above photo was actually taken in Melbourne, at Brighton Technical School, probably in 1942. (Here's another Australian one from the 1940s, and here's one from London in July 1940.) It's really just common sense: if the roof and walls are about to come crashing down and there's no time to get to a proper shelter, getting the students under their desks when the bombs started to fall would give them some protection and might save their lives.
I wonder about the handkerchiefs or rags the boys have in their mouths? My guess is that it's intended to guard against being choked with dust and plaster. Also, soaked in water, they might help against some forms of gas attack, such as chlorine. Soaking them in urine would be more effective, but that would probably be beyond the scope of most school gas drills!