We present an intertemporal portfolio choice model where individuals invest in financial literacy, save, allocate their wealth between a safe and a risky asset, and receive a pension when they retire. Financial literacy affects the excess return and the cost of stock market participation. Since literacy depreciates over time and has a cost related to current consumption, investors simultaneously choose how much to save, the portfolio allocation, and the optimal investment in literacy. This last depends on households' resources, its preference parameters and on how much financial literacy affects the returns on risky assets and the stock market participation cost, and the returns on social security wealth. The model implies one should observe a positive correlation between stock market participation (and risky asset share, conditional on participation) and financial literacy, and a negative correlation between the generosity of the social security system and financial literacy. The model also implies that the stock of financial literacy accumulated early in life is positively correlated with the individual's wealth and portfolio allocations later in life. Using microeconomic cross-country data, we find support for these predictions.