In this paper we identify conditions under which the introduction of a pay-as-you-go social security system is ex-ante Pareto-improving in a stochastic overlapping generations economy with capital accumulation and land. We argue that these conditions are consistent with realistic specifications of the parameters of the economy. In our model, financial markets are complete and competitive equilibria are interim Pareto efficient. Therefore, a welfare improvement can only be obtained if agents' welfare is evaluated ex ante, and arises from an improvement in intergenerational risk sharing. We examine the various effects of social security, on the prices of long-lived assets and the stock of capital, and hence on output, wages and risky rates of returns, can be clearly identified. In addition, we analyze the optimal size of a given social security system as well as its optimal reform.