Wealth transfer from the middle class to the capital-owner class within an economy still leaves the wealth in that economy, it just doesn't benefit the masses.

In terms of how the wealth flows into the economy in the first place, it's tech worker wages, which are of course taxed at a rate that would give corporations an apoplectic fit. The money that funds said corporations' needs in public infrastructure and educated workforce has got to be procured somewhere.