The purpose is to keep you cool. It works because water moderates temperature and evaporation breaks down bonds.
As mentioned above, humans have sweat glands over their entire bodies; the only place dogs (and cats, and many other animals with fur over their whole bodies) can get rid of excess heat is through the tongue. By the way, sweating/panting is NOT a means of getting rid of excess water; it is a way of getting rid of heat. We do this because of the process of evaporation. In changing from liquid to vapor, the water absorbs heat from the surface on which it is laying. Actually, most organisms do not want to get rid of excess water; they need to conserve it, but on very hot days animals "spend" the water to achieve the cooling.