Cockroaches and other small insects and animals can survive being in an operating microwave because these ovens do not uniformly heat the interior volume. Instead, they form hotspots approximately 7.5 centimeters apart that small mobile organisms instinctively avoid.
A microwave oven works by emitting microwave radiation from a magnetron on one side of the oven. The interior is lined with metal, which reflects microwaves back into the center. Water molecules are agitated by microwaves, increasingly vibrating and generating heat. The microwaves, being a certain length, only focus on four to five points within, creating enough space to avoid heating a small insect like a cockroach.