Firstly, diplomats and their families fall into this category. It also includes service personnel of the foreign embassies and foreign military people who stay in the UK officially, for example when they take part in combined exercises or provide security for the embassy.
It is obvious that this exception is made because of a special extraterritorial legal status of the groups mentioned above.