We have here an act of David which was highly praise-worthy, and yet it was utterly condemned by God. This is to show that all our devotion must be properly directed and that we are being thoughtless and presumptuous when we fail to recognise what is right, but instead imagine in our head that things are a certain way. It is true that David’s basic motive was good and holy -that is, to build a temple for God. For however much “he dwells not in a house made by human hands” (Acts 17:24), still he wanted to be worshiped in this manner during the time of the figure of the Law. But David was too hasty in not waiting for God to order him to do this, and so he took upon himself more than was appropriate for him. And yet it was not that he failed to handle himself with modesty, or that he failed to leave himself open to submitting to God. For he did not call in his counsellors so that he could tell them: “Here is what I have concluded -it must be carried out!” The pride of earthly kings is such that they want people to agree with them, and they want all that they have said to come into  effect. Well, David did not proceed to act so presumptuously. Rather, he called Nathan, the prophet. Indeed, although God had given him the spirit of prophecy to teach others, yet still he submitted himself to seek out the will of God. Nevertheless, he was still at fault, because in addition to addressing the prophet, he ought to have waited patiently for a fuller revelation to be given him. Be as it may, God undoubtedly approved his fervent zeal. And yet he kept him in check to show him what we saw above, that “obedience is better than sacrifice” (1 Samuel 15:22).
John Calvin, Sermons on 2 Samuel (Translated by Douglas Kelly), Edinburgh: Banner of Truth, 1992, p 295-296.