Most insects are solitary and come together only briefly for mating. They deposit their eggs in a suitable spot and go on their way.
Some insects are social to a smaller or greater extent.
Some carabid beetles aggregate under shelter during the day and forage at night during periods when in reproductive diapause. Again a pheromone causes the aggregation. Monarch butterflies and coccinellid beetles diapause in aggregations, again for mutual protection. For many species which aggregate in feeding you only see social behavior in early instars when they are most vulnerable to desiccation and predators. Later instars need more food and are more capable of defending themselves.