Diplomatic law is the law that governs diplomats from one country who are residing in or visiting another country. These laws dictate what a diplomat can and cannot do when they are on a diplomatic mission.
Ambassadors are the usually the highest ranking diplomats residing in foreign countries.
One of the laws that commonly applies to diplomats is diplomatic immunity. Diplomatic immunity is when a diplomat has protection from being sued by a host nation for various legal issues. Diplomatic immunity is often granted so that ambassadors and other diplomats can be guaranteed safe passage out of the host country.
If diplomatic law did not exist to protect diplomats, then countries would be more hesitant to send diplomats to foreign countries on diplomatic missions.