Sheep are very strong-willed and stubborn creatures. The shepherd must restore them to the right path. Sheep wander. Sheep are just not that smart and don't realize the grave danger they may be in. They may be headed toward a rocky ledge or in the path of a wild beast.
At twilight, in the evening, the shepherd always counts his sheep. If one is missing, he goes out to find it and restore it to the flock.
How think ye? if a man have an hundred sheep, and one of them be gone astray, doth he not leave the ninety and nine, and goeth into the mountains, and seeketh that which is gone astray? And if so be that he find it, verily I say unto you, he rejoiceth more of that sheep, than of the ninety and nine which went not astray. Even so it is not the will of your Father which is in heaven, that one of these little ones should perish. Matthew 18:12-14
If the sheep continues to wander, the shepherd takes his staff and breaks one of the legs of the sheep. That sounds cruel; but look at the shepherd's heart. He does not want to lose even one of his sheep. He makes a splint. He carries the crippled sheep in his arms. He gradually places him on the ground at his side until he can move on his own again. Chances are he will not wander again. That sheep has learned his lesson.
Sometimes GOD must break our hearts to learn the lesson of staying close to the Shepherd. Many trails entice us to stray. We choose them and end up wandering from GOD's trail. Some of these luring trails bring temporary pleasures, but the Shepherd loves us too much to let us stay there. That's when He breaks our legs (our hearts). He wants us to stay on the paths of righteousness. The only way we can stay of the right paths is to stay close to the Shepherd.
"Yea, though I walk through the valley of the shadow of death, I will fear no evil: for thou art with me; thy rod and thy staff they comfort me." The Shepherd provides protection along the trail. Sheep are defenseless and have reason to be afraid. They need a strong shepherd. Our GOD is a strong shepherd. He walks with us through every step of any dark valley. He doesn't take us around the valley. He doesn't fly us over it or tunnel us under it. He doesn't just miraculously remove the valley. He takes us through it.
Scripture indicates that His rod and staff comforts us. We can't see GOD. And we can't see His rod and staff. But they are there and they are there for our protection. It's not just any rod and staff. They are His. And it is great comfort to know that they are in the right hands.