Immune System HQ. The lymph nodes can be thought of as outposts for white blood cells. When there is an infection or inflammation in the area where a lymph node is draining fluid from, the white blood cells start to build up to fight it. This causes swelling in that node.
Monitoring Centers. Lymphatic system absorbs/carries things too big to go into the arteries/veins like bacteria eaten by white cells and digested food. Lymph nodes "taste" the lymph for anything bad like bacteria, viruses, cancers, etc. When it detects a problem, it alerts the immune system and your body reacts. They enlarge in response to the inflammation they create when they react. They shrink when all is well.