Samuel 6 is the companion text to this chapter and to 1st Chronicles 15. The point of this story is to tell how David brought the ark of God into Jerusalem. But, there are several lessons which we can learn from this narrative. Not the least of which is the inadequacy of good intentions alone. David had good intentions. He desired a wholesome thing. He wanted to bring the Ark of the Covenant to Jerusalem. However, 1st Chronicles 13:1 indicates that he had a poor source of counsel on how to go about doing this thing. He consulted with his military captains. And, evidently, what they knew was the story of how the Philistines had sent the Ark back to Israel on a cart.
So, David invited the whole nation to come to the parade. Since Saul had died for refusing to "enquire" at God's hand, David intended to rectify that situation by reversing the precedent (1st Chronicles 10:14 & 13:3). Notice specifically that EVERYBODY was on board with David's goal (1st Chronicles 13:4). One would think that since all were in agreement, God would turn a blind eye to any missteps, right? Wrong! He had clearly outlined the method, so, they were required to follow it (Exodus 25:14). Because David didn't check in the Law of Moses to see how to go about his task and because none of the Levites informed him about what was required, he did the right thing the wrong way and it ended up costing Uzza his life.