You have to remember that the last time David tried to move the ark it started tipping over and someone grabbed it and was struck dead (2 Sam 6.6). Then "David feared Yahweh on that day and said, “How can the ark of Yahweh come to me?”" (6.9)
and he "was not willing to bring the ark of Yahweh to himself, to the city of David, so David caused it to turn to the house of Obed-Edom the Gittite." (6.10).
So David needed to find a way to bring it Jerusalem safely. He finally did that with extreme reverence by sacrificing every sixth step. I view it as a charming tribute to the sabbath where the ark took six steps and then rested. It took six more steps and rested, etc. Interrupting the procession with sacrifices would also be consistent with traditional practice:
From the NICOT commentary:
Ancient Near Eastern literature refers to repeated sacrifices in
relation to processions accompanying the transfer and installation of
gods. As for the number of sacrificed animals, Solomon sacrificed a
multitude of oxen and sheep during the dedication of the temple. David
probably did not slaughter the animals himself, but this emphasizes
that he was the central character in bringing the ark to Jerusalem.
The purpose of sacrificing all along the way to Jerusalem is to
appease the Lord’s anger and please his God. The expression a bull and
a fatling could be a hendiadys meaning “a fatted bull.”
Tsumura, D. T. (2019). The Second Book of Samuel. (E. J. Young, R. K. Harrison, & R. L. Hubbard Jr., Eds.) (pp. 117–118). Grand Rapids, MI: William B. Eerdmans Publishing Company.