Infestations are an event and are a big threat. They can happen randomly or can be caused by a quest, quests will warn you if this is an outcome. Infestations can also occur upon entering rooms in an old ancient complex.
Insect hives spawn in an area below an Overhead Mountain and within 30 tiles of a colony structure. Other factors such as rock walls and light have some influence on their spawn point of choice. Temperatures under -8°C (17.6°F) gradually reduce the spawn chances, with the chance dropping to zero at -17°C (1.4°F). A well-lit base discourages insects from nesting, though it can still happen.
Upon spawning, infestation choose a single "valid" tile, i.e. one with Overhead Mountain and a temperature higher than -17°C (1.4°F), then spawn the hives in any available spot within a certain radius, regardless of whether those tiles are "valid" or not. Note that a hive may or may not spawn in the triggering tile.
This has two primary consequences. The first is, when spawn proofing a base, care must be taken to remove all valid tiles as even a single warm tile can cause a full infestation. Secondly, infestations can spread into seemingly safe areas, even if there is a wall between it and the spawning area. This is especially frequent with late game infestations, which are usually quite large and thus have larger spawn radii. This has the effect of allowing them to spawn pretty far inside your base.
Insectoids (Megascarabs, Megaspiders and Spelopedes) will spawn near hives and spend their time roaming around them. They will attack and chase any intruder that comes within a 10-tile circular radius from the hive that spawned them, returning to their hives once the threat is gone. Insectoids will only attack creatures they can see, and will not attack while they are sleeping provided they are not woken up.
If any of the insectoids is downed or damaged, the entire infestation will go after colonists on the map, attacking and breaking down structures in the progress. This also applies to outside factors, such as the insectoids being attacked by pirates or downed by hypothermic slowdown. After a while, the insectoids will give up and return to their hives.
Insectoids will also randomly dig at stone and structures while wandering around their hives, potentially breaching into new areas.
Infestations are most threatening in mountain bases, as they can spawn practically anywhere inside your base. They are much less harmful in other bases though, and can be considered as a normal-level threat there. Insectoids are melee fighters so colonists with ranged equipment can try to kill them from a safe distance. When fighting an infestation always ensure you completely annihilate every hive. If even one is left, insectoids can keep spawning and leave you back where you started. One way of dealing with infestations in mountain bases is to make the structure with non-flammable materials and wood floors/furniture on the inside. Once you have done this you can place an IED incendiary trap so insects trigger them and light themselves on fire with minimal risk to the rest of your base.
Since insectoids do not attack creatures while sleeping, it is possible to haul materials in and out of the area near their nests at night, including flammable material. This is however extremely risky, since attacking one of them or doing construction near the insectoids will wake them up. They also wake up when their individual need for rest has been filled.
When attacked, insectoids will go after colonists without any walls between them first. This allows the insectoids to be lured away from their hives, chasing a runner colonist across the map. While they are away the hives can be destroyed. As long as hives are being damaged, the insectoids will keep chasing after colonists instead of returning to their hives. To keep the hive destroying pawns safe from having the insectoids' attention turned to them rather than the runner, a wall can first be built to block off the insectoids from the hives. Note that some new insectoids are likely to spawn at the hives during the process. Once all the hives are destroyed, the insectoids will wander the map like normal animals and soon starve to death.
If you bait insects to spawn elsewhere the chance of an infestation spawning inside is greatly reduced. Temperatures above -8°C (17.6°F) have no bearing on hive spawning (e.g. very hot weather), neither does flooring. If spawned by a quest they may spawn outside in the open.
If you are able to ensure that there is only one valid spawn location on your base map, you can prepare this area to automatically trap and kill the insects when they appear. (Though never rely on this completely unless you know exactly what you are doing. If your base is in a mountain, be prepared for infestations no matter what.)
Another good tactic to avoid or minimize this risk of them spawning in your base is by strip mining into many different mountain areas. If you then segment the spaces under the mountain into rooms around 20-40 cells big, this will allow more spaces for the infestations to spawn, and can help drastically odds of one spawning in your base, that they may rarely spawn in your base.
If the hives are kept intact, they will reproduce progressively. If all Megaspiders or Spelopedes are killed, the hives will deteriorate due to lack of maintenance.
Hives spawn insect jelly in stacks of 20 units every day or so. You can farm these by building walls and doors, but insects may dig out and attack your colony. You can retrieve the jelly when the insects are asleep.
Hives also spawn glow pods, which provide light for 20 days (as long as they’re installed). These can only be reinstalled should the hive be destroyed in version stable 1.0.