"لَوْ عَلِمْتُ أنَّكَ تَنْظُرُ لَطَعْنتُ بِها في عَينِكَ، إِنَّما جُعِلَ الاسْتِئْذَانُ مِن أجل البَصَرِ".
A man peeped into the house of the Prophet ﷺ through a hole while the Prophet ﷺ was scratching his head with a Midrai (a certain kind of comb). On that the Prophet ﷺ said (to him), "If I had known you had been looking, then I would have pierced your eye with that instrument, because the asking of permission has been ordained so that one would not see things unlawfully."
أَنَّ رَجُلاً اطَّلَعَ مِنْ جُحْرٍ فِي دَارِ النَّبِيِّ ﷺ وَالنَّبِيُّ ﷺ يَحُكُّ رَأْسَهُ بِالْمِدْرَى فَقَالَ لَوْ عَلِمْتُ أَنَّكَ تَنْظُرُ لَطَعَنْتُ بِهَا فِي عَيْنِكَ إِنَّمَا جُعِلَ الإِذْنُ مِنْ قِبَلِ الأَبْصَارِ
that a man peeked in on the Messenger of Allah ﷺ, in one of the apartments of the Prophet ﷺ, while the Prophet ﷺ had a Midrah (an iron comb) with which he was scratching his head. So the Prophet ﷺ said: "If I knew that you were looking then I would have poked your eyes with it. Seeking permission has only been enjoined because of the sight."
أَنَّ رَجُلاً اطَّلَعَ عَلَى رَسُولِ اللَّهِ ﷺ مِنْ جُحْرٍ فِي حُجْرَةِ النَّبِيِّ ﷺ وَمَعَ النَّبِيِّ ﷺ مِدْرَاةٌ يَحُكُّ بِهَا رَأْسَهُ فَقَالَ النَّبِيُّ ﷺ لَوْ عَلِمْتُ أَنَّكَ تَنْظُرُ لَطَعَنْتُ بِهَا فِي عَيْنِكَ إِنَّمَا جُعِلَ الاِسْتِئْذَانُ مِنْ أَجْلِ الْبَصَرِ وَفِي الْبَابِ عَنْ أَبِي هُرَيْرَةَ
a man looked through a hole in the door of the Prophet, who had with him a kind of comb with which he was scratching his head, When the Messenger of Allah saw him he said: "If I had known that you were watching me, I would have stabbed you in the eye with this. This rule of asking permission has been ordained so that one may not look unlawfully (into people's houses). (Using translation from Nasāʾī 4859)
أَنَّ رَجُلًا اطَّلَعَ فِي جُحْرٍ فِي بَابِ رَسُولِ اللهِ ﷺ وَرَسُولُ اللهِ ﷺ يَحُكُّ رَأْسَهُ بِمِدْرًى فَقَالَ رَسُولُ اللهِ ﷺ «لَوْ عَلِمْتُ أَنَّكَ تَنْتَظِرُنِي لَطَعَنْتُ بِهِ فِي عَيْنِكَ إِنَّمَا جُعِلَ الِاسْتِئْذَانُ مِنْ أَجْلِ الْبَصَرِ»