Infestation is a random event.
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 gradually reduce the spawn chances, with the chance dropping to zero at -17°C. A well-lit base discourages insects from nesting, though it can still happen. If you bait insects to spawn elsewhere the chance of an infestation spawning inside is greatly reduced. Neither heat nor floors have any bearing on hive spawning.
Soon, Insectoids (Megascarab, Megaspider and/or Spelopede) will spawn near hives to defend them and, will attack and chase any intruder within a radius of 30 to 35 tiles and then return to their hives once the threat is gone.
If the hives are kept intact, they will reproduce progressively. But if either Megaspiders or Spelopedes are killed, the hives will deteriorate due to lack of maintenance.
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. Insectoids are melee fighters so colonist with ranged equipment can handle them at safe range. Their damage output can seriously injure poorly protected humans and of course much easily versus pets. When fighting an infestation always ensure complete annihilation so as to not let any remain standing. If just one hive is left unattended, they will recover easily turning a threat again just like at the beginning.
Hives spawn glow pods that light for 20 days (as long as they’re installed), it's lifespan corresponds with the cool down on the infestation. These items can be reinstalled or sold. Another product is the insect jelly in stacks of 20 units every day or so. You can farm these jellies by building walls and doors but insects may dig out and attack your colony. You can retrieve the jellies when the insects fall asleep.