Shoulders quickly loose their ability to function thru a wide range of motions, this is normal but a bit scary if you are getting old, or stop using them.
So of course the answer is to keep using them and keep them functioning thru a wide range of motion. If you are like me your range of motion might be compromised. When I was young I could shake hands behind my back! Now it's hard to scratch my back. The good news is it should come back with work. So heres a yoga pose, or stretch (first photo) and a stretch with sling, you can substitute a broom etc for this. Don't overdo this stretch do not pull agressivly, or past any real tolerence, it's a passive stretch at minimum or just where you engage the stiffness.
If you are stiff in this area, and nearly evey one is especialy males, a little work might be in order. I couldnt do a move the other day, I felt too short, the problem was lack of shoulder mobility.
Standing stretch you might notice it stretches the front side of your body, pecs and frontal deltoids. Like I said be really careful, dont blame me if you overdo it, take it easy.