Autopsies are not done all the time. They are usually done either for medical reasons, or for legal ones. One of the legal reasons why an autopsy is done is to find out if the death was the result of a crime. A medical case is to find the cause of death when it is unclear. Sometimes autopsies are done to train new doctors.
Sometimes, the cause of death can be found by simply looking at the corpse without opening it. In other cases, it may need to be opened, to find the cause of death. If it is opened, it is usually closed again; most of the time, corpses are buried. Before being buried, they are on display for some time. For this, they need to look acceptable. In certain cases, like when the corpse is opened, special permissions are perhaps necessary. These are usually given by the closest living relative, called next of kin.