A “whipping boy” is one upon whom is inflicted punishment for the faults or wrongs of another; a scapegoat.
Under the belief that the body of a young royal prince was as sacred as that of the king, his father, and that, accordingly, no governess nor tutor should chaitise him, a custom was introduced into England in the early seventeenth century to transfer any punishment merited by a princeling to the body of another.
The first to benefit was the son of James I, the young prince who later became Charles I.
The lad William Murray was appointed to be his playmate and fellow pupil, and to receive all punishment deserved by either of the two lads, to be the “whipping boy” of the prince and be flogged for all the faults of either.
The custom died out as the royal household became more democratic, but the allusion has remained.