Companion planting involves planting two or more plants in a way that at least one plant benefits from the other(s) to deter pests and attract pollinators. At the same time interplanting cuts down on competition for the sun and nutrients. If you practice companion planting, you will be practicing what natural plant communities have been doing for billions of years. In nature you can observe what plants grow well together.
The "three sisters" method from the Native Americans is a form of companion planting. Corn and beans were planted together with the corn stalks created a trellis for the beans to grow up on and the beans provided nutrients for the corn. Sunflowers grown in the same field protected the corn and beans from aphids. After harvest, the stalk and vines were left to compost.
Interplanting herbs with vegetables is a good mix. Planting basil with tomatoes is a good choice since the basil will detract the most common pests that affect the tomato plants's growth. Planting bee balm with tomatoes enhances the flavor of the tomatoes. Borage will attract bees to the tomato plants and create more tomatoes. Putting marigolds in with your vegetables is a great way to deter pests because of their awful scent. They will also brighten up your garden.
Some plants release nutrients into the soil that other plants will use. The legume family is well-known for being a nitrogen fixer that collect the nitrogen from the air, converting it into a nitrogen resource released in its roots, feeding other plants near-by. Beans and peas are a good cover crop to use in the winter, getting your soil ready for spring. Allowing some clover to grow in your garden beds feeds the vegetables and flowers with nitrogen.
Companion planting benefits you, the soil and nature.