The holy spirit works on our heart and on our mind to reveal how much better it is when we do what God would do or say what God would say. By practice over time we develop characteristics, we routinely behave as God would behave. Not because we should, or must, but because we choose to, we prefer to, because it is in our character to do so. Faithfulness is one of those god-like traits. Because we appreciate reliability in others we begin trying to be more reliable ourselves.
Reliability gradually becomes one of our characteristics.
What was unrighteousness in us gradually becomes God's righteousness in us. The answer lies in what God has told us that His objectives are for us. By learning to prefer His will, His way, and His ideas over ours. And we know that all things work together for good to them that love God, to them who are the called according to his purpose. We would be egotistical to think that we could become like Jesus merely by trying.