The standard explanation is that sweating evolved to keep us cool. But it doesn't make a lot of intuitive sense. Animals which survive in hot environments don't use sweat to maintain a managable body temperature. You would need a lot of water to drink for starters. It seems more likely to me that it was used to get rid of excess salt, similar to a marine iguana. If our ancestors started to pick fruit and seeds that had fallen into a marine estuary or delta from overhanging trees, then a pattern begins to emerge. The more seafood which is collected would slowly alter the physiology of the mammal group. Is this the secret of man's success?