It comes originally from the Book of Common Prayer, where there were two exhortation. First, to the congregation:
“Therefore if any man can shew any just cause, why they may not lawfully be joined together, let him now speak, or else hereafter for ever hold his peace.”
Then, to the couple themselves, the exhortation already quoted from Jane Eyre:
“I require and charge you both, as ye will answer at the dreadful day of judgement, when the secrets of all hearts shall be disclosed, that if either of you know any impediment, why ye may not be lawfully joined together in Matrimony, ye do now confess it. For be ye well assured, that so many as are coupled together otherwise than God’s Word doth allow are not joined together by God; neither is their Matrimony lawful.”
(Bronte engages in a bit of dramatic licence, in having an objection from the congregation being made after the second exhortation. In fact anyone in the congregation wishing to object would presumably do so in response to the first exhortation.)
SFAIK these exhorations were an innovation at the time of the Reformation. The Catholic Rituale Romanum in use at the time said that the celebrant was to satisfy himself that the couple were free to marry, but didn’t direct that he do this as part of the service itself. Practice as to doing this varied , I suspect, from place to place, with some places relying on a system of banns, others on licenses, etc. until a more centrally-controlled uniform system was introduced at the time of the Council of Trent, which didn’t involve exhortations of this kind.
I don’t think there was ever a civil legal requirement for these exhortations, except perhaps indirectly, if civil law required a celebrant to celebrate marriages according to the rituals of his particular church, and his particular church had rituals which directed the inclusion of the Anglican exhortations, or some variation on them.