We derive a firm's optimal capital structure and managerial compensation contract when employees are averse to bearing their own human capital risk, while equity holders can diversify this risk away. In the presence of corporate taxes, our model delivers optimal debt levels consistent with those observed in practice. It also makes a number of predictions for the cross-sectional distribution of firm leverage. Consistent with existing empirical evidence, it implies persistent idiosyncratic differences in leverage across firms. An important new empirical prediction of the model is that, ceteris paribus, firms with more leverage should pay higher wages.