That $5mm under your mattress is backed by bonds, income yielding bonds. That's why it's worth $5mm. If the country or bank that issues those bonds were defunct, the money would be worthless because the bonds would no longer be income generating.
You could say that gold is nonproductive wealth. Adam Smith sorta argued that gold isn't wealth. You could use a sack of grain as an example..
These examples are theoretical though. IRL, the majority of wealth is equity, bonds, real estate, etc. The value of that property is determined by the income it generates for its owner. If you really had that $5mm, it would probably be in equity, bonds, real estate, and generate a yield... like most wealth in the world.