The story
Originated in beth din courts in ancient Israel to show that God has the highest authority. It was later spread to England as a prayer for a criminal who was sentenced to death, and then the British Empire to indicate a death penalty.
Etymology from Wiktionary, CC BY-SA 4.0.