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.
Also word of note, in the late game, some infestations can be so large, that if even a small bit of your base in under a mountain that they are spawning in, and there is not enough space in said mountain, they will start spawning in rooms that have a ceiling inside your base, allowing them to spawn pretty far inside your base. Though more research needs to be done to fully confirm how this "infestation base overflow" occurs, it has been noted by several players. So please take note of this when building bases.
Insectoids (Megascarabs, Megaspiders and Spelopedes) will spawn near hives to defend them, attacking and chasing any intruder within a radius of 30 to 35 tiles and returning to their hives once the threat is gone. They will also randomly dig at rocks to expand their hive.
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.
If you bait insects to spawn elsewhere the chance of an infestation spawning inside is greatly reduced. Temperatures above -8°C 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 exactly what you are doing. If your base is in a moutain, 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.
Another product glow pods that 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.