Plants don't have goals, natural selection has selected for advantageous traits. It's not as though a plant could think 'I know, I want to get my seeds transported further away, I will make some fruit so that animals can transport them in their stomachs' - although I'm sure you're aware of this. Questions of purpose, and goals in evolution don't really make sense.
This is speculation on my part, so don't take it as fact, but it provides an example of how fruit might have evolved. If there was a plant that developed seeds, perhaps in a small juicy case (adapted for other purposes) that animals adapted to eat and subsequently poop out in a different area, inadvertently that plant would have created a means of spreading its seeds across a wider range - this would have an impact upon its success. The plants that provided the tastiest, most visible fruits would have an advantage over others, so there would be a trend towards sweeter, more nutritious fruit that was brightly coloured to stand out in high contrast against the green background. Over time fruit would get bigger and juicier because the bigger and juicier fruits would be more likely to get eaten, and thus have their seeds germinated (ensuring the survival of their genes into the next generation).
Its not as though the goal of the plant is to have it's fruit eaten, its just an advantageous way of doing things therefore it was selected for by natural selection.
It's similar to how some plants use insects to transport their pollen by bribing them with nectar or adapting to look like an insect (so that the insect will attempt to mate with it). They don't do so purposefully, it was just that natural selection blindly stumbled upon an advantageous way of doing things.