I'm no expert on companion planting, and there are whole volumes written on the subject. But in brief (and I don't pretend to be scientific about it!) there is a belief that certain plants do better when grown together. Sometimes one plant will keep harmful insects away from the other, sometimes one will bring useful insects to help pollinate the flowers of the other. Basil, for instance, attracts bees, which are needed to pollinate tomatoes, and so they make good companions. Sometimes you will have one plant some distance from another to act as a decoy. Garlic chives will attract aphids away from roses. Often you'll find that companion plants are members of the same family, and like the same conditions. Other times you'll find plants growing together that balance each other in their uses of nutrients - one may use a lot of nitrogen, the other might provide it.
Some act in other ways to be good companions. For instance, Anise deters pests from Brassicas by camouflaging their odour and improves the vigour of plants grown nearby. It deters aphids, fleas, reduces cabbage worms.Coriander and anise seeds sown together will germinate more quickly. Borage accumulates silica and potassium, of great use when growing flowering and fruiting plants such as Broccoli, Brussels sprouts, Cabbage, Cauliflower, Cucumbers, Pumpkin, Tansy, Tomatoes, Rose, Squash, Strawberries. Chillies help plants which are affected by root rot and other Fusarium diseases. French marigold kills harmful nematodes. Horehound improves the fruiting of tomatoes. Yarrow is a good companion plant for most plants because it provides a lot of nutrients for them, especially those will need to produce their essential oils (the highly perfumed plants like lavender and basil, for instance).
Yarrow is one of the so-called Physician Plants. Grown near a sick plant, it helps it to recover. Thyme is also a Physician Plant. So is marjoram/oregano.
Some plants will help prevent grass and weeds from growing nearby. One such is Arrowroot, another is comfrey. Comfrey also is an excellent companion palnt because it keeps soil rich and moist, accumulates calcium, phosphorus, silica, nitrogen, magnesium, potassium, and iron, acts as a trap for slugs and because the rotting leaves make good fertiliser.
I need to check this, but I think it's coriander which helps prevent fennel from seeding too much and becoming a weed, which it's otherwise likely to do. Fennel has the reputation for being the overall worst companion plant of all - it should be grown well away from other plants. It seems to inhibit the growth of many plants. Coriander (if such it be) is about the only plant which helps to control fennel.
There are definitely some scientific reasons for all these things - some answers are already provided. I have heard that elder is a bad companion plant because the roots produce some substance or other which kills off competition plants - and I have found it true that nothing much...
Q
Organization
Q