No, really, I'm dead. Just lying here, deceased and unmoving. Move along, nothing to see here but us dead bugs.
Things that eat other things tend to quickly lose interest in dead prey, so some insects that employ the strategy of playing dead (thanatosis) can often escape unharmed. Threatened insects simply let go of whatever they happen to be hanging on to and drop, motionless, to the ground where they put on the performance of a lifetime. Certain caterpillars, ladybugs, many beetles, weevils, robber flies, and giant water bugs all employ this technique. Guess what Death-feigning beetles do to protect themselves?
Acid & Burning Agents
Some bugs release irritants so awful that it automatically makes "get it off! get it off!" the only thing a predator thinks. It's not the most romantic defense mechanism, but it gives the insect time to escape. Some blister beetles produce a blistering (hmm, I think I know how they got their name) agent. Droplets of this will ooze from the beetle's leg joints when it is disturbed or threatened -- an adaptation known as reflex bleeding. Some termites, cockroaches, earwigs, stick insects, and beetles will literally spray acid at attackers. The (fantastic) bombardier beetle stores chemicals in specialized glands, and when threatened, mixes them together to produce a forceful discharge of boiling hot quinone and water vapor (steam). Seriously. That is @$#% awesome.
Some caterpillars have hollow body hairs that contain a painful irritant. Simply brushing against the pretty, soft-looking fluff will cause them to break and get all over your skin, resulting in an intense burning that may last for several hours. Many ants, bees, and wasps deliver venom to their enemies by means of a formidable stinger (modified ovipositor). The venom is a complex mixture of proteins and amino acids that not only induces intense pain but may also trigger an allergic reaction in the victim.
Speed & Movement
Some insects don't have fancy weaponry or acting chops and have to rely on speed to get away. For many insects, a quick escape by running or flying is the primary mode of defense.
Sure, Mr. Miyagi can catch flies with chopsticks, but can you? House flies have an insanely fast reaction time when you try to swat them. They can fly away 30-50 milliseconds after sensing a threat! And a cockroach? Those nasty things have tiny, super-sensitive hairs that are acute enough to detect the change in air pressure that might occur right before you try to step on them. It can react in less than 50 milliseconds. Just try and hit them with a newspaper. You can't do it.
Armor & Spines
Plenty of insects simply rely on their exoskeleton to avoid being eaten.
Large weevils have ridiculously strong armor and can actually bend insect pins when bug collectors try to add them to their boards. The Ironclad Beetle can literally be stomped on, and take zero damage. These guys don't just bend those insect pins, you need a drill to get through their shell. Then there are spines, bristles, and hairs that work pretty damn good in discouraging things that might be hungry. Nobody wants a mouthful of needles, and the hairier insects make for an unpleasant dining experience as well. Plus, insects like super-hairy caterpillars make it super difficult for parasitic flies or wasps to even get close enough to the insect's body to lay their eggs.
False advertising. Basically, these insects are piggybacking on a good thing that other insects developed the hard way. For example, Monarch butterflies have a free pass because they taste, really, really bad to birds. So the Viceroy butterfly thought to itself - ok, cool. And went off and bought the same dress. Viceroys look exactly like Monarchs, despite the fact that they taste just fine (I will have to take the word of birds on this). Many species of wasps, as we all know, have alternating bands of black and yellow on the abdomen. The robber fly has developed those same stripes in order to pass as something dangerous. There are spiders that mimic ants, flies that mimic bees, and even entire groups of insects display mass behaviours like beetle larvae that co-operate to mimic bees. Find something that's working for other bugs and copy it. Plagiarism at its finest.
Unlike the mimics, these insects have worked hard to blend in on their own terms.
Insects that blend in with their surroundings often manage to escape detection by predators and parasites. Birds can't eat what they don't see in the first place. This tactic involves not only matching the colors but also disrupting the outline of the body and eliminating reflective highlights. Also, holding very still... because once you move, obviously you won't look so much like whatever it is you're standing against. These guys usually stay close to home or make only short trips out and back - since their coloration tends to be area-specific. Lots of grasshoppers and katydids have colors that work great against a background of dried leaves or gravel, but not so well against green leaves. Conversely, other species that live in those leaves are usually a shade of green that matches.
This is different than mimicry or camouflage, though it uses the same principle. Some insects "hide in plain sight" by resembling objects in their environment. A thorn could really be a treehopper; a twig might be a walkingstick, an assassin bug, or a caterpillar; and sometimes a dead leaf turns out to be a katydid, a moth, or even a butterfly. Some caterpillars resemble bird droppings, and others have false eyespots on their wings or body to create an imitation of a predator's head. Often, these guys are the coolest-looking... the details in their appearance astonishing in their accuracy and creativity.
If there is one thing most of us have in common, it's a distaste for foul smells. And the really bad ones can be enough to make you recoil. Ever been at the epicenter of a skunk attack? It's like someone is burning tires directly in your NOSE. Stink bugs have special glands that produce a foul-smelling reek. The caterpillar form of some swallowtail butterflies have glands just behind their heads, that, when disturbed, will rear up and release a terrible stench. Darkling beetles will raise their big, black butt in warning when they are threatened, and if you don't pay attention to the warning - will expel acrid, foul-smelling fluid.
When stink and burning isn't enough, some bugs will hit their attackers with sticky compounds that harden like glue and incapacitate. Some kinds of cockroaches guard their backsides with a slimy anal secretion (those are three words that are just terrible together) that cripples any ants that launch an attack. And there are types of soldier termites that have nozzle-like heads that can spays sticky, immobilizing toxic fluids at attackers as varied as ants, spiders, centipedes, and other predatory arthropods.
A lot of times, insects that tend to spray acids or release stench, will be brightly colored or have contrasting patterns that tend to attract attention. All animals, even humans, tend to be suspicious of what seems too good to be true. Imagine if you were walking and there was a neatly wrapped Twinkie just sitting in the middle of the sidewalk. Odds are, you wouldn't touch it. Because... why is it just sitting there? Why hasn't anyone else eaten it yet?
For these bugs, predators quickly learn to associate these distinctive colors and patterns with an "unpleasant" outcome, and it only takes one faceful of acid to learn not to bother with that bright, red stripped beetle again. Yes, that first dude who got eaten died... but his sacrifice was not in vain. And his brothers and sisters live on in his memory.