A Commentary, Critical, Practical, and Explanatory on the Old and New Testaments, by Robert Jamieson, A.R. Fausset and David Brown  at sacred-texts.com
psa 51:1On the occasion, compare Sa2 11:12. The Psalm illustrates true repentance, in which are comprised conviction, confession, sorrow, prayer for mercy, and purposes of amendment, and it is accompanied by a lively faith. (Psa. 51:1-19)
A plea for mercy is a confession of guilt.
blot out--as from a register.
transgressions--literally, "rebellions" (Psa 19:13; Psa 32:1).
psa 51:2Wash me--Purity as well as pardon is desired by true penitents.
psa 51:3For . . . before me--Conviction precedes forgiveness; and, as a gift of God, is a plea for it (Sa2 12:13; Psa 32:5; Jo1 1:9).
psa 51:4Against thee--chiefly, and as sins against others are violations of God's law, in one sense only.
that . . . judgest--that is, all palliation of his crime is excluded; it is the design in making this confession to recognize God's justice, however severe the sentence.
psa 51:5His guilt was aggravated by his essential, native sinfulness, which is as contrary to God's requisitions of inward purity as are outward sins to those for right conduct.
psa 51:6thou shalt make, &c.--may be taken to express God's gracious purpose in view of His strict requisition; a purpose of which David might have availed himself as a check to his native love for sin, and, in not doing so, aggravated his guilt.
truth . . . and . . .wisdom--are terms often used for piety (compare Job 28:28; Psa 119:30).
psa 51:7A series of prayers for forgiveness and purifying.
Purge . . . hyssop--The use of this plant in the ritual (Exo 12:22; Num 19:6, Num 19:18) suggests the idea of atonement as prominent here; "purge" refers to vicarious satisfaction (Num 19:17-20).
psa 51:8Make . . . joy--by forgiving me, which will change distress to joy.
psa 51:9Hide, &c.--Turn from beholding.
psa 51:10Create--a work of almighty power.
in me--literally, "to me," or, "for me"; bestow as a gift, a heart free from taint of sin (Psa 24:4; Psa 73:1).
renew--implies that he had possessed it; the essential principle of a new nature had not been lost, but its influence interrupted (Luk 22:32); for Psa 51:11 shows that he had not lost God's presence and Spirit (Sa1 16:13), though he had lost the "joy of his salvation" (Psa 51:12), for whose return he prays.
right spirit--literally, "constant," "firm," not yielding to temptation.
psa 51:12free spirit--"thy" ought not to be supplied, for the word "free" is, literally, "willing," and "spirit" is that of David. "Let a willing spirit uphold me," that is, with a soul willingly conformed to God's law, he would be preserved in a right course of conduct.
psa 51:13Then--Such will be the effect of this gracious work.
ways--of providence and human duty (Psa 18:21, Psa 18:30; Psa 32:8; Luk 22:32).
psa 51:14Deliver--or, "Free me" (Psa 39:8) from the guilt of murder (Sa2 12:9-10; Psa 5:6).
righteousness--as in Psa 7:17; Psa 31:1.
psa 51:15open . . . lips--by removing my sense of guilt.
psa 51:16Praise is better than sacrifice (Psa 50:14), and implying faith, penitence, and love, glorifies God. In true penitents the joys of pardon mingle with sorrow for sin.
psa 51:18Do good, &c.--Visit not my sin on Thy Church.
build . . . walls--is to show favor; compare Psa 89:40, for opposite form and idea.
psa 51:19God reconciled, material sacrifices will be acceptable (Psa 4:5; compare Isa 1:11-17).