On average, the molecules in a glass of water do not have enough heat energy to escape from the liquid. With sufficient heat, the liquid would turn into vapor quickly (see boiling point). When the molecules collide, they transfer energy to each other in varying degrees, based on how they collide. Sometimes the transfer is so one-sided for a molecule near the surface that it ends up with enough energy to 'escape' (evaporate).
Evaporation is an essential part of the water cycle. The sun (solar energy) drives evaporation of water from oceans,lakes, moisture in the soil, and other sources of water. In hydrology, evaporation and transpiration (which involves evaporation within plant stomata) are collectively termed evapotranspiration. Evaporation of water occurs when the surface of the liquid is exposed, allowing molecules to escape and form water vapor; this vapor can then rise up and form clouds.