It definitely often feels like the value capitalism places on certain skillsets is out of sync with the true intrinsic societal value. It ultimately boils down to the law of supply and demand, a brutally unemotional, uncaring concept.
At least in part it's not just supply and demand, but what capital owners have deemed your value is worth, and how much value you can produce for them given your role. A programmer at a big co can take that 300-500K/year you pay them and multiply it 10x, creating a lot of "value" due to far reaching impact at scale.
That is still supply and demand. The "demand" part comes from what you wrote about - how profitable the capital holders believe their tech ventures will be - this sets the ceiling for tech salaries. Currently, the capital holders are still very optimistic, which makes us in this profession still in very high demand.
It's not just supply and demand. Many farmers effectively price their own labor below the market rate. They are essentially subsidizing their customers by continuing to farm out of habit or tradition or love even when when it doesn't make sense from a purely financial standpoint. The rest of us get artificially cheap food so we don't look too hard at the situation, but it probably isn't sustainable.