When they fly right up your nose or wave at you from the sugar bowl, you might not be very thankful for insects.

Insects evolved 400 million years ago, among the first animals to “crawl out of the sea, shake off the mud, and ... get wings,” says Katy Prudic, an entomologist at the University of Arizona.

“When Earth’s oxygen levels shrank, so did the insects”—allowing them to breathe and escape predators more quickly.

Insects evolved to be so tough and adaptable that they survived several mass extinctions. (The only exception is the Permian-Triassic, about 252.2 million years ago, in which huge amounts of carbon dioxide seeped into the atmosphere over thousands of years, Prudic says.)

View Images Monarch butterflies sun themselves in Michoacan, Mexico. Photograph by Frans Lanting, National Geographic

At least 850,000 known insects exist worldwide, including Antarctica (the wingless midge), leaving us wondering: How have these tiny creatures achieved world domination?

Getting Defensive

For starters, insects produce dizzying numbers of offspring that require little to no care.

The African driver ant, for instance, produces three to four million eggs every 28 days—a record for a species with advanced social organization.

View Images Driver ants move across the landscape in Ghana. Photograph by Joe Blossom, Alamy

Bugs can even use bombs.

“The bombadier beetle will emit a tiny bomb in the mouth of anything that tries to eat it,” Prudic says. It's actually a pulse of hydrosulfuric acid (watch video), but would you try tasting it twice? (Related: "Battle Ready: 5 Insects Prepared for War.")

See the Awesome Wrestling Moves of the Leaf-Footed Insect

Others are so deft at disguises they can get—or avoid being—lunch. The orchid mantis masquerades as a harmless orchid to deceive prey. The walking leaf insect rocks back and forth to mimic a real leaf being blown by the wind. And the lichen-colored katydid blends in with its lichen-encrusted host tree to hide (and even eats the very lichen it is camouflaged to match). (See "Find the Mimic" in National Geographic magazine.)

And if insects attack in self-defense, some have some painful stings that would deter predators from making another go.

View Images A ladybird beetle, also known as a ladybug, feeds on an aphid, a type of pest that can destroy crops. Photograph by George Grall, National Geographic

Justin Schmidt, author of The Sting of the Wild, writes that the worst insect stings—at least to people—are tarantula hawks, which he describes in his book as "blinding, fierce, shockingly electric,” and warrior wasps as simply “torture." (Read "Worst Places to Get Stung? Ask This Guy.")

Keep Calm and Carrion

And while insects are helping themselves, they're helping us in the bargain.

Insects are major predators of other insects, including pests, Schmidt says via email—ladybugs feed on crop-destroying aphids, for example.

The tiny invertebrates also do huge favors for our agriculture and environment. They till, enrich, and aerate the soil, as well as disperse seeds and pollinate about a third of food produced worldwide, notes Prudic.

View Images Burying beetles prepare to bury a kangaroo rat. Photograph by Darlyne A. Murawski, National Geographic

Then there are the cleaners, like carrion beetles, which rid our land of rotting corpses by dragging them off, laying eggs in them, and feeding their offspring the flesh.

Dung beetles are “ultimate recyclers,” keeping us from being knee-deep in poop by feeding on and breaking down other animals’ waste, Anne Estes, of the University of Maryland School of Medicine, says via email.

Dung beetles also move those feces-derived nutrients into the soil and out of creeks, rivers, and lakes, where it can do harm to livestock, Estes says. (It's also nicer for people to enjoy a more poop-free environment as well.) Some, like the rainbow dung beetle, look fabulous while doing it.

That’s a lot of work. Anyone know where to get a quintillion thank-you notes?