Narrated Sahl bin Sa'd: A man peeped through a round hole into the dwelling place of the Prophet, while the Prophet ﷺ had a midrai (an iron comb) with which he was scratching his head. the Prophet ﷺ said, " Had known you were looking (through the hole), I would have pierced your eye with it (ie, the comb)". Verily! The order of taking permission to enter has been enjoined because of that sight, (that one should not look unlawfully at the state of others).
The Prophet ﷺ also taught us that we should respect other people's privacy and not intrude on them without asking for permission first. We should always be mindful of our actions and be respectful towards others in order to maintain peace and harmony in society.