How the Stock Market Drives Wealth Inequality