An ambassador is a person sent by the government of a country to a different country. The ambassador is the official representative of their country. The ambassador speaks to officials of the other country about any problems and issues between the two countries.
In past years, communication between countries could take days or weeks. It was necessary to have a person in each foreign capital to have meetings and make negotiations between countries. Nowadays, communication is much faster, and often governments can be in direct contact with each other. However, it is still true that many problems need person-to-person meetings, so ambassadors are still needed.
Often an ambassador will live in the foreign country for a number of years. An embassy is where the ambassador lives. Embassies are most often in the capital of the foreign country. An ambassador may bring people with him to help him and work at the embassy. Some of the high ranking people may be called embassy officials.
It is both tradition and law that the ambassador and many embassy officials have diplomatic immunity. They cannot be arrested or prosecuted in the foreign country. The only possibility is to send a person back to their own country.