It was because Locke so readily felt the structures of social control in the society in which he lived to be legitimate that he rejected their abuse with such intensity.
John Dunn, The Political Thought of John Locke: An Historical Account of the Argument of the ‘Two Treatises of Government’, Cambridge, 1969, p. 167
To suppose that there are (positive) legal reasons why a formally valid law can be voided for moral impropriety is a logical error. To suppose that all formally valid laws are morally obligatory is a moral error.
John Dunn, ‘Consent in the Political Theory of John Locke’, The Historical Journal, vol. 10, no. 2 (1967), p. 153-182