Answer: This is one of the benefits of a practice called companion planting. Science is making headyway with understanding the mechanisms that are at work, but there is lots of ancecdotal evidence that certain plants grow better when paired with certain others. For instance, in the example you've given, one plant acts as a repellent to a pest of its companion. In other cases, plants have complementary needs for available resources, or can actually change the soil environment in ways that benefits its neighbor. There are entire books on the topic, such as "Carrots Love Tomatoes."
Q&A Library Searching Tips