They are also important pollinators. For millions of years, plants have evolved a delicate relationship with insects. Flowers produce nectar to attract insects. This movement of pollen around the flower increases the likelihood that seeds will be produced in the female part of the flower. The relationship can be so specific that some plants in the world can only be pollinated by one species of insect.
Host plants are food plants for caterpillars.
Again, there are some butterflies that will only lay eggs on specific plants for their caterpillars.