Utility maximization: equalizing marginal utility per dollar
Key Questions

Answer:
For a consumer, optimal consumption occurs when the ratio of marginal utilities equals the ratio of prices.
Explanation:
In this figure, note that the budget constraint is the diagonal line. The slope of the line is the ratio of the prices of good x and good y. The optimum consumption occurs at the highest level of utility  and utility is constant along each of the indifference curves (the concave lines).Where the indifference curve is tangent to the budget constraint (Point A), we know that utility must be maximized. At this point, the slope of the budget constraint line is equal to the instantaneous slope of the indifference curve. Since the indifference curve shows the preferred tradeoffs between good x and good y, this instantaneous slope is just the ratio of the marginal utility of a unit of good x to the marginal utility of good y  or:
P(x)/P(y) = MU(x)/MU(y).
Note also that at the optimal point A,
MU(x)/P(x) = MU(y)/P(y)
This is a highly mathematical explanation, but we can express it simply in terms of rational decision making and preferences. In determining my optimal consumption bundle, I will spend an additional dollar according to what a dollar's worth of each good will bring me in terms of satisfaction or utility.
For example, I have an optimal ratio for beer and pizza (even if I do not calculate it), and I'll spend my money accordingly  not all on beer and not all on pizza but in the combination where the additional utility for another dollar's worth of beer is the same as the additional utility for another dollar's worth of pizza. This does not mean an equal ratio, and my preferences are subjective, of course.