I have read as an example that Moringa thrives in sand. Evidently it is grown in desert like conditions.
How does this plant provide the benefits to humans still under these conditions?
Where does the plant get the nutrients in the first place to pass along?
Most sand has some finer material in it. And a little organic material. There is some pretty pure sand in nature like some sand dunes but most has some other material that will hold nutrients. Or finer material at depth but within reach of plant roots. It doesn’t take much to support some plants.
If you grow plants to study the effects of nutrient deficiency you need very clean sand in order to cause a deficiency. And you need the right sand. Some will provide a little nutrients itself.
It all comes down to adaptation. You are a warm blooded mammal. Around here the moose that meanders all winter long in -25f weather, sustaining itself eating bark and twigs is also a warm blooded mammal. You stand 0 chance at getting use to the moose environment and diet the same as many plants that stand the same odds at getting used to a completely different environment to the one they like.
It boils down to the magic of sex. 300 million years ago (give or take, can’t remember exactly, but I think it was a Tuesday) plants evolved to have flowers and thus sexual reproduction. This promiscuous mixing of genes send adaptation into overdrive to the point that in short order flowering plants became the dominant species in the entire planet. Before it was covered in ferns and fern trees. In order to compete and survive plants become specialists in regards to their growing condition to the point that they will favor an specific set of parameters over any other.