Most herbivorous insect larvae are more or less stationary – caterpillars are an exception, not the rule. Therefore, it’s up to the egg-laying mother to choose carefully where her eggs will hatch to make sure the larvae have a good shot at surviving to adulthood, by weighing the potential effects of plant nutritional quality, competition from other insects and favourable environmental conditions.
The main factor is finding the appropriate host plant – some species can only tolerate a single one, but most have a range of plants they can use. This is usually not a conscious decision though – throught he plant-insect coevolution, insect species have evolved hardwired attractions and repulsions to the plants in their ecosystems. If a plant gives off no repellants, or gives off attractants, the insect will land there. Then it will feel around the leaves/stem – this is where individual decision-making comes into play, where past experience, environmental conditions and even the female’s physiological state come into play to decide whether this is an appropriate place to lay her eggs. The largest factor at play here is mechanic: plant volatile chemicals are only used to detect the plant.
One particular case where the mother has to make a judgement call is in spacing her eggs properly. As I mentioned, many species have immobile larvae – if too many eggs are in one place, the resource will be overcrowded and there will be too little food. Nobody can benefit from this.
The judgement is made based on chemicals. When laying their eggs, the females will also spread pheromones over them to signal to other females of the same species that this place is taken. These pheromones were first discovered by Prokopy (1972) in apple maggot flies and since then, report have drastically increased and they’re found in all relevant insect orders.
There are other ways in which overcrowing can be detected. Some, like cowpea weevils, not only use chemicals, but can also count the numebr of eggs (remarkable, given the sheer number of eggs present in a batch). The way that stinks the most of coevolution (that’s a good stink, like the smell of your own toilet) is the one found in olive fruit flies. The deterrent here is simply olive oil. When the larvae begin feeding on the olive fruit, of course all sorts of juices will come out of the olive – they contain the chemical deterrents that tell other olive fruit flies that this place is taken and they should look elsewhere. That they co-opted the olive’s own chemicals for this purpose is pretty damn cool. This type occurs in several other insects, by the way.
Prokopy RJ. 1972. Evidence for a marking pheromone deterring repeated oviposition in apple maggot flies. Environmental Entomology 1, 326-332.