We develop a model where risk-averse workers can costly invest in their skills before matching with heterogenous firms. At the investment stage, workers face multiple sources of risk. They are uncertain about how skilled they will turn out and also about their income shock realizations at the time of employment. We analyze the equilibria of two versions of the model that depend on when uncertainty resolves, which determines the available risk-sharing possibilities between workers and firms. We provide a thorough analysis of equilibrium comparative statics regarding changes in risk, worker and firm heterogeneity, and technology. We derive conditions on the match output function and risk attitudes under which these shifts lead to more investment and show how this affects matching and wages. To illustrate the applied relevance of our theory, we provide a stylized quantitative assessment of the model and analyze the sources (risk, heterogeneity, or technology) of rising U.S. wage inequality. We find that changes in risk were the most important driver behind the surge in inequality, followed by technological change. We show that these conclusions are significantly altered if one neglects the key feature of our model, which is that educational investment is endogenous.