Plain water, as opposed to food, does not contain sugar nor proteins, so thus it is easily contaminated by microbes. There is a scientific explanation for the unusual taste of the water which has been in a glass during the night.
In fact, water that has been exposed to air for some time absorbs small amounts of CO2 and a tiny portion of it is converted into carbonic acid. This means that water changes its chemical composition, according to Discovery News.
When carbonic acid releases one or two protons, and turns into a bicarbonate or carbonate, that lowers the pH of the water due to which it alters the taste.
Moreover, this water that has been in a glass for several hours, has also been exposed to bacteria, and has also accumulated dust.
This does not mean that the water has gone bad, but bear the above in mind, so next time think whether you will drink this kind of water or you will reach for a fresh one.