9 “Against You alone have I sinned, and before You an evil thing have I done”. What is this? For before men was not another's wife debauched and husband slain? Did not all men know what David had done? What is, “Against You alone have I sinned, and before You an evil thing have I done.” Because You alone are without sin. He is a just punisher that has nothing in Him to be punished; He is a just reprover that has nothing in Him to be reproved. “That you may be justified in Your sayings, and conquer when You are judged.”
To whom he speaks, brethren, to whom he speaks, is difficult to understand. To God surely he speaks, and it is evident that God the Father is not judged. What is, “And conquer when You are judged”? He sees the future Judge to be judged, one just by sinners to be judged, and therein conquering, because in Him was nothing to be judged. For alone among men could truly say the God-Man, “If you have found in Me sin, say.” But perchance there was what escaped men, and they found not what was really there, but was not manifest.
In another place He says, “Behold there comes the Prince of the world,” being an acute observer of all sins; “Behold,” He says, “there comes the Prince of this world,” with death afflicting sinners, presiding over death: for, “By the malice of the devil death came into the world.” “Behold,” He says, “there comes the Prince of the world:”— He said these words close upon His Passion:— “and in Me he shall find nothing,” nothing of sin, nothing worthy of death, nothing worthy of condemnation.
And as if it were said to Him, Why then do You die? He continues and says, “But that all men may know that I do the will of My Father; arise, let us go hence.” I suffer, He says, undeserving, for men deserving, in order that them I may make deserving of My Life, for whom I undeservedly suffer their death. To Him then, having no sin, says on the present occasion the Prophet David, “Against You only have I sinned, and before You an evil thing have I done, that You may be justified in Your sayings, and conquer when You are judged.”
For Thou overcomest all men, all judges; and he that deems himself just, before You is unjust: Thou alone justly judgest, having been unjustly judged, That hast power to lay down Your life, and hast power again to take it. Thou conquerest, then, when You are judged. All men Thou overcomest, because You are more than men, and by You were men made.
Source: The Enarrations, or Expositions, on the Psalms (New Advent)