How to purify your self, how to purify your thoughts in an instance where we are not capable of doing bad things?

1- Remind yourself how generous Allah has been with you. He has created you. He wants the best for you. Thinking about His blessings purifies the mind.
2- Remind yourself that every sin is ugly and despicable. When you internalize that, you won’t think of sinning.
3- Train yourself not to be attached to materialism. Are you willing to let go of money and comfort? The more willing you are, the purer your soul becomes.
4- Want goodness for others. Don’t be jealous of anyone. Realize that anyone who has anything is from Allah. Love what Allah Has done and what He’s given to people.