Take a close look at any window on a plane they can consists of three panes middle one has a tiny hole.
When plane is up in the sky there is huge pressure difference inside and outside cabin. Outer plane built up more pressure whole in the middle regulates the pressure difference to make sure the passengers don’t experience a lack of oxygen.
And also big difference in temperature inside and outside the holes keeps the window fogging up.