In simple terms, the technical and detailed theory goes something like this: Plants developed tasty fruits so that animals, by eating them, would disperse their seeds.
(animals; would disperse; their seeds) (Plants; developed; tasty fruits)
animals Plants
would disperse developed
their seeds
tasty fruits