Things like carrots, dill, parsley, and parsnip will attract praying mantises, ladybugs, and spiders. These predator species of insects feast on the bugs who like to ruin your tomatoes, so it’s a win-win for the tomatoes (and you)!
This is also why it’s a great idea to interplant flowers with your vegetable plants–particularly marigolds and nasturtiums. These flowers will attract and feed beneficial pollinator insects, which will increase the fruit-set of many squashes, peas, cucumbers, tomatoes, and other veggies. Nasturtiums are edible flowers and look lovely in salads, and their nutritious root, called mashua, used to be a staple crop in South American regions.
Finally, some plants simply don’t get along, and won’t do well when they’re forced to share root space. Peppers and beans don’t like being next to each other, nor do potatoes and tomatoes (both members of the nightshade family). Peas prefer being far away from onions, and lettuces do not like to be near broccoli plants.