He wanted to show that even though he was acting under the law and considered rightous by those enforcing it, he was committing a sin in gods eyes.
He wanted to show no matter how great our sin, if we repent and ask forgiveness we can be saved by grace not by our works.