The Japanese tea ceremony, called "chanoyu", was established during the Sengoku period and the Azuchi-Momoyama period. Uchimizu is performed as a courtesy during tea ceremonies.
During the Edo period, Uchimizu was written about in haiku poems and depicted in Ukiyo-e woodblock prints, suggesting that it was a common way to cool off.
In addition to easing summer heat, it's thought that Uchimizu was performed to keep dust off the streets, welcome guests by sprinkling water at the entrance or on the road, and purify the atmosphere.
Source: "Uchimizu" chronology (excerpt) (2009, Shigenori Asai, Japan Water Forum, a nonprofit organization)