Regarding David you are right he shed a lot of blood for God. It was necessary at the time to establish the nation, but as a consequence there are things David is not allowed to do for God because he was a man of war.
1 Chronicles 28:2-3 2Then King David rose to his feet and said, "Listen to me, my brethren and my people; I had intended to build a permanent home for the ark of the covenant of the LORD and for the footstool of our God. So I had made preparations to build it. 3"But God said to me, 'You shall not build a house for My name because you are a man of war and have shed blood.'
Heres a little information about just how scarade the Ark of the Covenant was.
The real significance of the Ark of the Covenant was what took place involving the lid of the box, known as the "Mercy Seat." The term ‘mercy seat’ comes from a Hebrew word meaning “to cover, placate, appease, cleanse, cancel or make atonement for.” It was here that the high priest, only once a year (Leviticus 16), entered the Holy of Holies where the Ark was kept and atoned for his sins and the sins of the Israelites. The priest sprinkled blood of a sacrificed animal onto the Mercy Seat to appease the wrath and anger of God for past sins committed. This was the only place in the world where this atonement could take place.
Read more: What is the Ark of the Covenant?
In the passage I quoted we see God telling David because of the blood shed he's not even fit to build a room for the Ark on his behalf.