The immune systems main function is to fight disease and keep the body healthy. However, much like the other systems, a high/low blood sugar level can affect the system's ability to work effectively, especially in those who are diabetic.
According to a study done in 1973 by the Loma Linda University, eating excess amounts of sugar can decrease white blood cell capacity by almost 40%. This is because the white blood cells require vitamin C in order to fight off viruses and infection. However, when sugar competes for room with vitamin C within the WBC and ends up being more prominent in the bloodstream, the WBC isn't able to use the vitamin C to fight off infection as efficiently. The prolonged consumption of sugar can actually lessen the system's strength overall.
Diabetes and its effects
A study by Case Western Reserve University showed how diabetes (high blood sugar levels) negatively affects the immune system. The immune system uses select (protein) molecules to trigger inflammation and the fighting of an infection; however, people with diabetes have less of these molecules due to the fact that they are damaged by the increased blood sugar levels. When the body has diabetes, the sugar releases destructive molecules that alter the structure of infection fighting peptides such as hBD-2. The molecules found with diabetes, known as dicarbonyls, do this by attaching themselves to amino acids on the peptide and inhibiting their normal functions. When sugar is excessively consumed alongside having diabetes, it just continues to increase blood sugar levels and "deactivates" a lot of the infection fighting/inflammation molecules within the body. Due to this, it can also slow down the process of healing; this is because the cells become overwhelmed with the byproduct molecules of high blood sugar and don't function efficiently.
Immune system malfunctions
According to an article by Al Hoepelman, there are a lot more microorganisms that become virulent in the presence of high glucose. It is also much easier to adhere to "diabetic" cells than it is to non-diabetic cells. Overall, people with diabetes have a much higher risk of infection and it is advised that high blood sugar levels be lower due to all its negative effects in the body.