So in Psalms 51 we know that David wrote this after he sinned with Bathsheba (2 Samuel 11), the wife of Uriah. Later by the Word of the Lord, Nathan came at rebuked him. David repented, but by consequence his son born by Bathsheba died. David writes in verse 8 of chapter 51, "Make me to hear joy and gladness; that the bones which thou hast broken may rejoice." David before being a king was a shepherd. When a sheep is prone to straying, the shepherd would take the sheep and break it's back two legs. Then picking up the sheep, and placing it upon his own shoulders. The shepherd would carry the sheep while the legs healed. In the process the sheep would be solely in the hands of the shepherd, and trust being made. So there is pain for the moment, but after the legs heal, the sheep sticks closer to the shepherd than any of the sheep. This parallels with David completely, and David knew this all to well from being a shepherd himself. So yes, sometimes God has to break us, in order to build us. In Hebrews 12:6 it says, "For whom the Lord loveth he chasteneth, and scourgeth every son whom he receiveth." Though the bones break, rejoice, because the will heal stronger!
Always remember to wrap your life around the Word of God, and not the Word of God around your life! :)
Hope this helps!