This short article gives a better explanation than I could ever give at this hour of the morning:
https://www.theguardian.com/uk-news/2022/jul/14/what-does-qu...What is sovereign immunity?
Sovereign immunity is a centuries-old doctrine dictating that the monarch cannot be prosecuted or subject to civil legal action under the law. Its origin lies in doctrine and convention, rather than statute, and there is no law setting out the rules underpinning the concept.
It stems partly from the medieval concept that the monarch is the source of justice, and can therefore do no wrong. It also relies on an argument that because the courts belong to the Queen she cannot be compelled to appear in them, since she would, in effect, be prosecuting herself.
Since at least 1800, the monarch has also had a legally distinct private persona, created to allow them to have independent wealth and property that could be inherited by their children. However, the lines between the two are somewhat blurred, and sovereign immunity has typically been interpreted to apply to both the public and private identities of the monarch.