Usually a green, sour fruit is just a fruit that's not ripe yet. If you left a lime on the tree longer would it eventually change color and become sweet, like an orange?
Color changes
Actually, limes do become much more yellow and less sour as they ripen. Under ripe limes are darker green and quite bitter. There are other clues to their ripeness too. Ripe limes are heavy with juice and more aromatic, with a fragrant "limey" smell.
Most fruits we eat use similar cues to advertise ripeness.
Why would plants want parts of them to be eaten?
Fruiting plants have evolved a partnership with certain animals in order to increase the success of their seeds.
Tasty fruit pulp is the reward plants offer to animals in exchange for dispersing their seeds.
Frugivores
Plants attract fruit eaters--or "frugivores"--by packing valuable resources into their fruits like sugar and water or important nutrients such as carotenoids, vitamins and minerals.
Plants often target specific animals that will give their seeds the best chances for germination, and discourage or repel animals that won't.
Attract and repel
Plants that want to attract birds rather than mammals might produce thorns or have fruits that taste unpalatable to most mammals but tasty to birds.
Plants that want to repel birds but attract mammals might have fruits with thicker, tougher outer skins.
Don't forget that selective breeding by humans has dramatically changed many fruits from their wild state, often resulting in larger, sweeter fruits with fewer seeds.
Read More: Plant-Animal Interactions: An Evolutionary Approach (Amazon)