Mitzvah 263) That the Cohanim (Priests) should not become impure with the impurity caused by a dead body
“Say to the Cohanim the sons of Aharon… he may not become impure for a soul amongst his people!” (Vayikra 21:1)
It is a negative commandment that a regular Cohein may not become impure with the impurity caused by a dead body, (unless it is for one of the close relatives mentioned in the verse), as it says “He may not become impure for a soul amongst his people!”, which means to say that a Kohein may not become impure because of a corpse.
Amongst the roots of this commandment are that the Kohanim were chosen for the service of Hashem and therefore he distanced them from dead people, as the point of impurity is that it is disgusting, and the body of a dead person is the highest possible level of impurity. The reason for this is that when the body loses its appearance of life, it remains with just the material of the body, which is flesh which always aspires to all the evil things, and in its evilness it caused the soul to sin even when the soul was still in the body. It is therefore fitting that it should defile all its surroundings, and that the servants of Hashem should distance themselves from it. It is, however permitted for the Kohanim to become impure for their close relatives as they are their own flesh and the ways of the Torah are all pleasant and its paths are peace, and Hashem did not want to give pain to a Kohen by saying that at the time of the decease of a close relative they are not allowed to enter the place where the body is and cry and express their agony over it.
This commandment applies to male Kohanim, in all times and places, but not to females.