Companion Planting for Pest Control
It's long been noticed that some plants grow better with other plants. Sometimes the reasons are not clear. Other examples are easier to explain.
Some plants repel some insects. Marigolds and nasturtium are often named but many of the aromatic herbs including thyme and basil as well as the onion families have this property.
The IOWA State University, conducted a research project on companion planting with tomato, zucchini lettuce cabbage and broccoli and various herbs and flowers. They found a respectable improvement in pest infestation win the plants which were companion planted. It's a good article well worth reading.
The experiment does nothing to explain why, but it definitely shows that there is an effect.
Several mechanism are probably at work in keeping the pests away. The most commonly mentioned one is that the companion plant produces some insect repellent. This is likely the case for the aromatic herbs. It is well documented that catnip produce insect repellent substance as do many more. Here is a list of pest repelling plants from Wikipedia
Catnip is one of the plants and I plan to try it in my garden this summer. I have used it as biting insect repellent and I know it works.
Attracting good Insects
Many flowering plants are very effective in pest control not because they repel pest but because they attract the insects that eat the pests. This is the case of nectar producing flowers that feed the good insects as adult. In turn the larvae of the good insect eat garden pests. Lacewing is an example, but many of the predatory wasps also are attracted to flowers. The wasps then sting their prey and infect them with their larva. The wasp larva then eat the insect pest (or caterpillar).
Colorado State U has an article on Growing plants to attract beneficial insects
Some experiments in England have shown that planting the edges of crop fields with appropriate flowers reduce the number of harmful insects in the crops.
Planting Bait Plants
Another way a plant can benefit from companion planting is by having a companion that is tastier to the pest than the vegetable. Insect pests come along and instead of settling on the crop, they are lured to the bait plant. It is important to control the pest on the bait plant otherwise the bugs will also eventually go to the good plants too.
Camouflaging the Crop
The larger the concentration of tasty crop plants, the more likely they are to be attacked. This is because single planting emphasize and concentrate whatever it is that attracts the bad bugs. Whether the bugs hunt by smell or sight, a mixed planting will be less obvious and harder to detect than a large number of crop plants all together.
The more successful planting schemes will likely benefit from several mechanisms. Good plants will disguise the crops while feeding the predator insects and actually repelling the pests.
Some plants produce toxins
Some plants can kill insects and pests. An example of this is marigold, Chrisantemum or castor bean that that produce substances that not only repel insect pests but also are toxic to several pest including nematodes.
Colorado State U has an article on Here is an article on nematode control in the Home Vegetable Garden, and a list of Nematode suppressive plants by the Alabama Cooperative Extension system.
This information is for general knowledge.