This paper develops a microfounded macroeconomic modeling framework to investigate the relationship between informality and the income distribution. We show that multiple equilibria may rise if credit markets are imperfect and that there is a nondivisible entry cost in the formal economy. The theoretical analysis demonstrates that in the steady state, low levels of inequality are negatively correlated with high informality; conversely, high inequality exacerbates informality. This finding supports the hypothesis of an optimal level of inequality that minimizes the informal economy relative to the impact of other levels of inequality. However, for ordinary income distributions, changes in the level of inequality have only a slight effect on the informality rate. We calibrate the model using data on the U.S. and Mexican economies to estimate the level of inequality that minimizes the informality rate. The self-employment rate emerges as the most relevant determinant of the informality rate.