Pain causes weakness. Weakness causes pain.
Both of those statements are true and set up a vicious cycle in bodies that have chronic pain.
There are by-products of muscular contraction that in large enough concentration can cause a muscle to contract creating a self perpetuating spasm. This is helpful if you are running through the jungle away from an enemy and you have a hairline fracture that you need splinted; not so helpful if you are sitting at your desk for hours.
Strength training is one way to pump out those materials. Strength training can create muscle bulk that provide spacer materials that takes pressure off of nerves and blood vessels, it stimulates capillary action increasing nutrition on a cellular level. There are many sites that explain the hows and whys of that physiology. I simply suggest that you be aware some exercises can contribute to poor patterns of motion if you push too hard, too fast, or power through repetitions mindlessly trying to just get them done. Awareness of the desired outcome, if you are trying to change a pattern of motion, can lead to slight modifications in angle or performance strategies that promote your body moving in a way that is less painful even when you are not paying attention.