"And all the people when they heard, and the publicans, justified God, being baptized with the baptism of John." (Luke 7:29,RV)
John preached the baptism of repentance, and those who were baptized by him confessed their sins. Thus they justified God; for it is God who declares that: "All have sinned." (Romans 3:23)
And whosoever confesses that he has sinned, thereby declares God's justice. He confesses that God is just in His sayings and in His judgments, as David said in his confession: "Against You, You only, have I sinned, and done this evil in your sight; that You might be justified when You speak, and be clear when You judge." (Psalm 51:4)
But, "If we confess our sins, He is faithful and just to forgive us our sins, and to cleanse us from all unrighteousness." (1 John 1:9)
If we justify God, we shall partake of His justness. God has no good thing that is not for His children; and we get His goodness by acknowledging it. If we recognize and acknowledge His power, we receive of that power.
If we truly acknowledge the perfect righteousness of His word in every particular, we shall be filled with that righteousness. "And this is life eternal, that they might know You, the only true God, and Jesus Christ whom You have sent." (John 17:3)--Present Truth, May 24, 1894--Timeline: IV-32 (Jesus' Eulogy of John)--Luke 7:29.