Cactus fruit is not generosity. It is a survival contract written in sugars, acids and spines, forged by drought and hungry animals sharing the same harsh stage.
The basic trade is blunt. Bright, water rich berries lure birds and mammals, which then move the seeds. But that sweetness rides on the back of stress machinery: to endure low water and high light, cactus tissues ramp up pathways like the shikimate route and phenylpropanoid metabolism, generating flavonoids, betalains and other secondary metabolites that protect membranes, proteins and DNA from oxidative damage.
What looks like a bonus for us is collateral output. Compounds such as polysaccharides that seal water in the stem also modulate human immune responses; betalains that shield chloroplasts from ultraviolet radiation act as antioxidants in our blood; alkaloids and sterols that deter herbivores can affect human pain perception, inflammation and glucose regulation. Under strong selection for drought tolerance and defense, these molecular defenses accumulate in the same tissues that become fruit pulp or stem extracts.
Animal appetites then refine the recipe. Frugivores prefer pigments they can see and tolerate, so lineages whose fruits packed effective yet nonlethal doses of these molecules won more seed dispersal. Over long stretches, that feedback tuned flavor, color and pharmacology together, leaving a plant that feeds bats at night, scars desert winds by day, and stocks human pharmacies almost by accident.