The paper develops a stylized overlapping generations economy with random production and a stock market. The impact of a Social Security system on production, asset markets, and consumer welfare is analyzed. It is shown that any reduction in the contribution rate fosters capital accumulation and increases asset prices, wages, and production output. Different welfare criteria are applied to determine the optimal size of Social Security. It is shown that there exists a unique contribution rate which is long-run optimal, socially optimal, and time-consistent in the sense that no generation has an incentive to change it.