There are all kinds of muscles that surround the shoulder. If biomechanics are jeopardized, the shoulder will not function properly. Every joint has a muscle and a tendon that support it. The muscles tell the bone structure what to do. If the muscles do not have full functionality, they will eventually cause strength and flexibility issues in the joint along with the minor aches and pains in the surrounding areas. By generating elasticity (massage) within the muscle, you are building a sound platform for structural integrity and positive biomechanics.

A triathlete has three disciplines: swimming, biking, and running. During prolonged periods of swimming the form can diminish. Once you become tired, the shoulders take the responsibility for most of the stroke and start to lose power. Then, the pectorals (in the front, chest) take the slack for the exhausted shoulder. Once engaged, tight pectorals force the shoulders to rotate forward.

If you were to compare all the muscles that surround the shoulder, the largest and most influential are the pectorals. Please keep this in mind as you try to gain more range of motion in the shoulder.
When cycling, the shoulders take on additional weight because they are supporting the entire upper body (especially while the forearms are in the aero-bar position). Also, as the elbows are positioned closer together, the pectorals actually become engaged while riding. Once you use your hands as leverage, the pectorals will respond even more.

When running, the shoulders tend to rotate forward because they have maintained this position for a prolonged period while on the bike in the aero position (during triathlon), therefore cutting off oxygen to the lungs. The arms also start to swing across and in-front the body rather than along the sides of the hips, swinging front to back. At this point the biomechanics of the upper body are blown. Flexibility and strength are totally an issue at this point.

To counteract this biomechanical challenge, all of the muscles in the upper body have to be structurally sound with proper flexibility and strength, otherwise the chest is going to overpower the shoulder. Many have been misguided and told to strengthen and massage the back muscles in order to pull the shoulders back versus allowing the shoulders to rotate back naturally. By generating elasticity in the pectorals, you will minimize the stress on the upper back, allow the shoulders to relax to their natural position, and open up the diaphragm to allow better oxygen intake.

All this being said, it is not just about triathlon. This can affect non-athletes as well.
During everyday activities, the pectorals can be overworked causing the shoulders to rotate forward. Anytime the hand is in front of the body the chest or pectorals are being used. Think about how much time you spend on the computer, talking on the phone or driving with one hand over the steering wheel. All of these activities are going to affect the trapezius, neck, and of course the shoulder. The pectorals will challenge the smaller muscle groups.
As you sleep, typically you roll to one side or the other. This is going to cause you to lose elasticity within the shoulder and chest. The body tries to repair the damage that has been done during the day at night while you sleep. If you cut off blood flow to the shoulder area, you may be sore when you wake up, and your flexibility may be challenged.
Recommendations:
Strengthen the muscles surrounding the shoulder while at the same time creating flexibility and elasticity within the pectoral major and minor (chest area) so the shoulder can rotate back naturally. Then, address other challenged areas as there may be adhesions, scar tissue, and trigger points which can add to improper biomechanics. Massage can assist in regaining flexibility, elasticity, and strength allowing the muscle to function optimally.
As a runner, allow the shoulder to rotate back naturally. This will also allow you to lead with your pelvis with less effort.
As a swimmer, loosen up the chest before getting into the pool. This will also allow you to keep the elbows high with less effort.
If you work at a desk, keep the shoulders relaxed while working at the computer.
As you drive, keep both hands on the wheel. Don't lean to one side and put the opposite hand over the steering wheel.