Sweating when we have a fever is a regulatory mechanism to ensure the fever doesn't get too high, but is high enough to help fight the infection. If we ran a fever the temperature may steadily climb until its at the level where we sustain cellular damage.
Hence when children get fevers the emphasis is to bring it down, as they are susceptible to febrile convulsions.
As BC said we also sweat out toxins, as I understand it,it is toxins released by virus/bacteria, and also chemicals from the immune system,that trigger the hypothalamus to raise our core temperature, so it could be that these toxins are released through sweat. Perhaps it is a negative feedback loop, the higher the level of pathogen toxins the higher the temperqure is set, or the more likely the hypothalamus is to raise the temp. The when the temp is raised, and we sweat, toxins are passed out, leaving a lower level in the body and thus our temp drops again. his would account for the temperature spikes common with infection.... but that really is just a guess on my part.