Like people plants too have their own social structures. there are some plants that enjoy each others company living synergistically with each other and others that that just don't tolerate each other.
Companion planting can be used to create better health in your plants, yeild more fruitful crops and of course to control pests and diseases.
The first plant too think of when companion planting is Marigolds, the smaller taget's species they help maintain good health and keep a large number of pests at bay they also go well with almost any plant.
Another good plant to have is chives, planted with roses and veges they keep the aphid population down though any good sulphur derived plant will do just as well, such as garlic .
a good tip with veges is that if they go well on the plate they go well in the garden. tomatoes and basil are a perfect example. tomatoes should never be planted without basil as it keeps alot of the pests away from your crop.
Tansy is a good plant to keep to control flys, umbelliferous family such as carrots and dill are good as they attract feeders such as ladybirds and wasps which will feed on other less desirable insects.
As far as plants that dont go well Rue is a good example, plants either seem to die or just don't thrive at all when in this plants vicinity. Rue can be used to discourage fleas though.
although this is just a brief summary the world of companion planting is very complex the volume of which could quite easily fill a large book so if your serious about plants, its a subject worth the read.