Mill observes that the sentiment of justice has peculiar intensity and apparent absoluteness: we feel that justice is not merely expedient but required, that its violation is a wrong calling for punishment, and that its demands cannot simply be traded off against other goods. He traces this feeling to two sources: the natural impulse to retaliate against harm (which we share with many animals) and the distinctively human capacity to extend sympathy to others beyond oneself. Justice is the moralised form of self-defence, extending its protection to all members of the community.
Mill argues that justice is not opposed to utility but is a particular and especially urgent subset of it. Just conduct — protecting rights, keeping faith, maintaining impartiality — is the most important kind of useful conduct, because the conditions it maintains (personal security, reliable expectations, equal treatment) are more vital to human welfare than any other social good. The sense of absolute obligation attached to justice reflects not that it transcends utility but that it represents utility at its most indispensable: what no community can exist without.
Rights, on Mill's account, are interests that society has an obligation to defend because they are so important to human welfare that no other consideration should be allowed to override them in ordinary circumstances. To have a right is to have a valid claim on society's protection. This is a utilitarian account of rights — they derive their force from utility — but one that explains why rights feel so much more binding than ordinary utilitarian calculations: they protect the conditions without which human beings cannot flourish at all.
Chapter 5 of Utilitarianism develops the account of justice. It has been immensely influential in the utilitarian tradition, anticipating later discussions by R.M. Hare and in the "rule utilitarianism" literature.
