The aim is only to allow diplomats to carry out their functions with security and confidentiality, and also to recognise diplomats' function as representatives of their country. It does not grant them freedom to flout local law, although they may be immune to local jurisdiction to enforce such laws. Contrary to a widespread belief, a diplomatic mission is not "extra-territorial": it is, however, given the protection of inviolability within the receiving state. This rule refers to its premises and diplomatic dispatches. But all privileges and immunities are solely directed towards facilitating performance of diplomatic missions.
The principle of diplomatic immunity was not formally established by international agreement until 1961 and rests on the principle of reciprocity: the main reason to treat other people's diplomats with respect is that if you do not your own are placed in jeopardy, writes Christopher Bellamy.