The Medrash Tanchuma explains this pasuk with a moshol of a butcher who used to frequent the king’s palace. The king told him, “I decree that you may never see a dead body. Since you frequent my palace, and see my face, I do not want you to make my home impure.”
So too, Hashem decreed that since the kohanim frequent His house, the Bais Hamikdosh, that they should not come into contact with the dead.
The Izhbitzer Rebbe zy”a (Sefer Mei Hashiloach) writes that the butcher’s job was to provide food for the king and thereby make him happy. The king does not want any sadness to mix into his joy, so he decrees that the butcher should stay away from things that make him sad. So too, the kohanim’s job is to bring influences of simcha down to this world through their avodah, and, therefore, they cannot come into contact with the dead, as this will cause them to feel sadness.