The first time David went to get the Ark of the Covenant, he did it with great fanfare and pomp. He had 30,000 men with him and followed the same method that the Philistines had used the last time the Ark had been transported. He used a cart. And, the cart was guided by 2 men who had lived in the same house where the Ark had been housed before David came to get it.
You know the old saying, familiarity breeds contempt. Evidently the familiarity that one of those men (Uzzah) had, caused him to consider the practicality of things to be a higher priority than the commandments of God. By divine decree, nobody was ever supposed to touch the Ark; under penalty of death. But, when it became unsteady on its cart, Uzzah disregarded God's demands and grabbed hold of the holy box. Immediately, he fell dead.
This incident displeased, frightened and frustrated David. He stopped the transport there right away and left the Ark in the house of Obededom. However, over the next 3 months, God blessed Obededom and his house so much so that it convinced David to try again to fetch the Ark. Somewhere along the line in that intermission, he must have taken the time to obey Deuteronomy 17:18-19; that is to read the Law of Moses. And, in reading it he surely must have encountered Exodus 25:14 and discovered just exactly what the proper method for carrying the Ark was. Isn't it amazing how much a little Bible reading can make a difference?!
Now, when David came into Jerusalem with the Ark in his caravan, he was so thrilled about it that he removed is royal robes and danced in celebratory worship in plain garments. Now this was a good and wholesome thing... but David's first wife Michal wasn't impressed at all. In fact, she was evidently embarrassed by David's display of humility and his unabashed public exhibition of genuine love for God. So, when he came home from worshipping... intending to bless his family, she met him with criticism and ridicule; even accused him of showing off physically and carnally in front of the women who were watching the parade that day. Her willingness to debase his pure and simple way of demonstrating his faith angered David deeply... so much so that he essentially relegated her to the status of a divorced wife. Since she rejected his God, he rejected her.