It is narrated from Sayyiduna Anas (may Allah be pleased with him) that a Bedouin came to the Noble Prophet (peace and blessings be upon him). When he stood up, he began to urinate in a corner of the mosque. The companions (may Allah be pleased with them) of the Messenger of Allah (peace and blessings be upon him) shouted at him, but the Prophet (peace and blessings be upon him) stopped them from doing so. Then he called for a bucket of water and poured it over the place (where the urine was).
From this hadith, we learn about the Prophet Muhammad’s (sallallahu alayhi wa sallam) character, which was full of wisdom and compassion. There were many hidden wisdoms in not stopping the man from urinating: firstly, if he had been scolded, his urine might have stopped abruptly and he could have suffered some harm; secondly, if he had gotten up and run away in that state, his clothes and a larger area would have become impure; thirdly, he might have become disheartened and run away, thus being deprived of the light of guidance.
Furthermore, this hadith mentions the sanctity of the mosque. In another hadith, it is stated that the mosque is for worship and was not made for (acts like) urination, etc. It is also established that the place where urine falls should be washed with water, because urine is impure, and that place becomes impure due to it.