The thermal energy of the water. Because the water is waaay above Absolute Zero (0K, or -273,15 C) it holds thermal energy or aka the temperature of the water. If the temperature of the water is higher than the one in the thermometer, the heat will 'flow' into the liquid (mostly mercury or modern, it is ethanol), causing the liquid to rise since it's volume increases. The same when te water has lower temperature. The thermal energy of the thermometer will 'flow' in the water and the volume shrinks, causing the liquid to go down. Simple thermodynamics.