The shoulder joint is a very complex one.  Think of all the movements it can do as opposed to the knee! This is only possible because it is a ball and socket joint and there are several muscles around it that allow these movements. All these muscles are meant to work together as a team to keep the ball centered in its socket allowing space between the two for all the other elements (tendons, ligaments, bursa, etc).  When your shoulder hurts it means that some muscles are working too much while others are not doing anything resulting in a compression of the elements and very often inflammation and/or impingement.   The right exercises would activate the lazy muscles taking some of the workload off the overactive muscles.