When multiple stakeholders are affected by the solution of an optimization model, fairness may be a concern. We investigate the utility distributions across stakeholders that result from maximizing total utility subject to a resource constraint and a bound on inequality, the latter measured by the utility range or the Gini coefficient. We find that in both cases, the optimal solution consists of only two or three utility levels, and if there are three, those on the lowest level receive nothing. We provide closed form solutions that depend on the resource costs of generating utility for individual stakeholders. These results suggest that the occurrence of two or three major socioeconomic classes in many societies may be partially rooted in the mathematics of optimal distributions.