Did you know that when cold-blooded creatures like snakes are infected, they seek warmer environments to raise their temperature? We warm-blooded mammals show similar behaviors, but they are overshadowed by our more efficient thermoregulation. What is it about elevating our temperature that confers a survival advantage significant enough to get a snake to look for a warm rock, even if it is exposed to predators; and for warm-blooded mammals to have febrile responses? What was evolution up to?
Some basics. Fever is an elevation of our body’s temperature outside what we consider a normal range – that means that 98.6°F is not ‘normal’ but the anchoring average. Temperature, like all physiologic measures, has a spectrum or ‘normal’ range. When temperature is too high, say over 105°F our proteins begin to change shape and function less efficiently. When temperature is too low, say less than 95°F metabolism slows reducing our energy supply. Temperature varies with our metabolic activity, higher in the afternoon and lower just before we awake.
How our bodies generate heat
Deep in the brain, the hypothalamus is the body’s thermostat; it is highly vascular and lacks the usual blood-brain barrier, which blocks the entrance of many chemicals, making it responsive to bloodborne chemical messengers. One group of messengers, pyrogens, stimulate hypothalamic cells to increase body temperature. Thermoregulation is primarily mechanical, our arteries dilate, allowing heat to radiate from our bodies, or constrict holding our temperature closer to our core. Metabolism also plays a significant role in raising our temperature (thermogenesis). Shivering generates heat when a muscle engages in small, uncontrolled movement. Non-shivering thermogenesis comes from uncoupling the energy normally used for cell function, allowing it to be dissipated as heat.
Why our bodies generate heat
There is evidence that fever plays a vital role in infection. Studies have shown that a 1-4°C increase in body temperature is associated with improved survival, but this doesn’t explain how fever helps in fighting infection. 
Fever’s effects are partially direct. Some infectious pathogens are less likely to reproduce when we are febrile, poliovirus replicates 200-fold less in this range, and some gram-negative bacteria are more susceptible to destruction by elements in our blood. And it may be that some antibiotics are more effective in the febrile range. But fever’s most significant actions are on the immune system.
The immune system consists of two components. First, there is the ‘innate’ immunity consisting of neutrophils, macrophages, and dendritic cells. These ‘first responders’ constantly circulate in our bloodstream, like an Uber driver during a surge, and eat up (phagocytosis) or break down (cytolysis) pathogens at the site of infection. They simultaneously attempt to localize the infection and signal the hypothalamus for more defenses. These responders use chemical signals, cytokines, but one in particular, IL6 appears to have multiple roles. IL6 increases production of hypothalamic cyclooxygenase2 (COX2) which in turn increases the production of PGE2 which in turn causes the hypothalamus to raise our body’s temperature by constricting our blood vessels to retain heat and generating heat through shivering and non-shivering thermogenesis.  Temperature in the febrile range increase the ability of these first responder cells to accumulate where they are needed, to eat and break up pathogens more readily and release additional cytokines. So the first advantage that fever confers is more rapid, effective localization of the infection.
Dendritic cells and macrophages are also intermediaries between the rapid ‘innate’ immunologic response, and ‘adaptive’ or learned immunity. T and B cells hold our immunologic memory, once exposed to a foreign compound like bacteria or viruses they remember, and on their next exposure, they produce lots and lots of antibodies that facilitate the destruction of those pathogens. Lymphatics are a relatively unrecognized third circulation, acting as a kind of sump pump, pulling fluid out of our tissue and returning it to our circulation. Lymph nodes are the rest stops of the lymphatic turnpike. T and B cells are found in the lymphatics, circulating throughout the peripheral tissue several times a day, being exposed to potential pathogens. IL6 directs macrophages and dendritic cells to bring their pathogenic prisoners to the lymphatics especially those lymph node rest stops where they can be exposed to T and B cells. IL6, the cytokine released by the early responders also increases lymph circulation while adding enough stickiness to get those T and B cells to hang around the lymph node rest stops for a while. T cells have a better chance of being activated because they have a better chance of being exposed to pathogens. So, fever’s second advantage is that it increases the likelihood that antibodies will be produced and help overwhelm the infection.
Fever resulting from infection reflects a tightly coordinated exchange of chemical signals between our brain and immune system. The evidence suggests that evolution conserved the fever response because it makes the immune defenses more efficient – the survival benefit outweighs its metabolic cost. The immune systems first responders are the central players, signaling danger through cytokines, limiting infection, and raising your temperature, so they work more effectively. They also take measures to recruit help from T and B cells. Evolution is a beautiful thing.
 There are other causes of fever. It can be due to inflammation or certain drugs which stimulate immune responses. Trauma to the hypothalamus can result in loss of temperature regulation but interestingly enough, in those cases, the temperature is lower. Finally, excess thyroid hormones, which facilitate energy production may increase energy production’s thrown-off heat.
 The increased production of COX2 is inhibited by a large group of drugs we commonly use to reduce inflammation like aspirin or ibuprofen