The Old and archaic concept of Sovereign immunity that "King can do no wrong" still haunts us, where the state claim immunity for its tortious acts and denies compensation to the aggrieved party.
The doctrine of sovereign immunity is based on the Common Law principle borrowed from the British Jurisprudence that the King commits no wrong and that he cannot be guilty of personal negligence or misconduct, and as such cannot be responsible for the negligence or misconduct of his servants. Another aspect of this doctrine was that it was an attribute of sovereignty that a State cannot be sued in its own courts without its consent.
During the orthodox middle ages, the power of the clergy was considered absolute in England. And the Crown, by virtue of protecting the interests of the church enjoyed sovereign immunity.
Pope Gelasius I opined on the general principles that underlie sovereign immunity:
There are two powers, August Emperor, by which this world is chiefly ruled, namely, the sacred authority of the priests and the royal power. Of these that of the priests is the more weighty, since they have to render an account for even the kings of men in the divine judgment. You are also aware, dear son, that while you are permitted honorably to rule over human kind, yet in things divine you bow your head humbly before the leaders of the clergy and await from their hands the means of your salvation. In the reception and proper disposition of the heavenly mysteries you recognize that you should be subordinate rather than superior to the religious order, and that in these matters you depend on their judgment rather than wish to force them to follow your will.
In a constitutional monarchy the sovereign is the historical origin of the authority which creates the courts. Thus the courts had no power to compel the sovereign to be bound by the courts, as they were created by the sovereign for the protection of his or her subjects.
Sovereign immunity is available to countries in international court but if they are acting more as a contracting body (example: making agreements in regards to extracting oil and selling it), then sovereign immunity may not be available to them.
Sovereign Immunity and its Exceptions
About two decades ago, hardly anyone would have cared about waivers of state sovereign immunity from suits based on constitutional law. Traditionally, waivers played only a small and subordinate role in the long saga of state sovereign immunity theory.
POSITION IN UNITED KINGDOM
The position was drastically altered for the United Kingdom by the Crown Proceedings Act 1947 which made the government generally liable, with limited exceptions, in tort and contract. Even before then it was possible to claim against the Crown with the Attorney-General's fiat (i.e., permission) (a petition of right). Alternatively, Crown servants could be sued in place of the Crown, and the Crown as a matter of course paid any sums due. Further, mandamus and prohibition were always available against ministers because they derive from the royal prerogative.