Why is there a hole in one of the layer of an airplane's windows?
Aircraft windows are multiple layers thick. The side facing the passengers is just a plastic sheet, since they wouldn't want the passengers scratching up the actual expensive glass window. Beyond the inner pane there are two actual structural window panes. The outer one is normally the one bearing the load, while the inner one serves as a backup.
However, since pressure changes in the cabin during the flight, it's also necessary to equalize the pressure between the window panes, and hence the little hole. A hole of that size would not jeopardize pressurization even if the outer pane blew out. Note the label &quot;Breather Hole&quot; in the diagram below.

There is a rubber seal around the outside of the two panes so it would be a bit of a pain to open a hole to cavity from the side. Apart from that, the windows are pretty tight together and by keeping it where it is there is nothing in the vicinity such as dust that could gradually be pulled in.
Since the air in between the panes is colder, it's not unusual to see ice crystals forming around the hole as the more humid cabin air enters the cavity.

(source: gentex.com)
787 Window
This diagram includes the electric shade system of the 787 which is fairly similar. Since the two outermost panes carry no structural purpose you can just have them equalize air as you please.