Bees have evolved all different manners of behaviors which promote survival. One of those mechanisms is to keep the interior of the hive clean and Hygienic. We see hygiene being practiced by the overall colony and also on an individual level of the worker bee.
The colony as a whole will show clean behavior by never excreting any waste inside the hive. On nicer warm days usually in the afternoon, you will see bees coming out and performing cleansing flights. Basically, they will not go to the bathroom inside the hive. They will fly out and circle in front of the hive before they deposit their waste.
We see other cleanliness behavior in the role of the housekeeping bee. Bees move through different jobs inside the hive during their lifespan. One of those jobs is one of cleaning the inside of the hive. This involves cleaning debris and also carrying out the dead bees. Instinctively bees will fly out a distance from the hive in one last act before they die. However, if they die inside the hive, the cleaning bees will carry them out and deposit them in front of the hive.
Cleaning the hive and cleansing flights are all behavior which take energy and pose significant risk to the individual bee. But the long term survival of the colony is increased with this behavior.
Be careful, you might get pooped on. Do not worry, it is only pollen and nectar.