According to water chemist Susan Richardson no proper studies have ever been conducted to answer this question. However, there are lots of possible explanations. In the UK and US, chlorine is added to drinking water to keep the public water system clean.
As it comes out of the tap, it still contains traces of the chemical, but left overnight, some of the chlorine will evaporate, changing the taste. Carbon dioxide dissolving in water makes it more acidic, and other chemical contaminants from the air could also affect the flavour.