Swelling/Edema and pain in any part of the body are signs of some kind of damage to that part. The main reasons for this are given below:

Main reasons for swelling and pain
Injury/Trauma: Due to a fall, blow, bruise, or injury to the muscles or ligaments (e.g. sprain), blood flow to that part can increase and swelling and pain can occur.

Arthritis: Inflammation in the joints causes joint pain and swelling. Rheumatoid arthritis is an example of this.

 

Infection: Bacterial infections (such as cellulitis) can cause the area to become red, swollen, and painful. It may feel warm to the touch.

Allergy: When an insect bites or comes into contact with an allergen, the area may suddenly swell and feel painful or itchy.

Poor Circulation: Venous insufficiency can cause swelling and pain in the legs.

Overuse: Continuous overuse of the same muscle or joint (e.g., walking for long periods of time or doing strenuous work) can cause swelling in that area.