After Yaakov's children took the spoils from the war against Shechem, Yaakov told them (35:2) vehitaharu betochechem vehasiru et elohei hanekhar asher betochechem vehachalifu simloteichem, "Discard the alien gods that are in your midst; cleanse yourselves and change your clothes." Rashi explains that he meant that they should discard the avodah zarah items and avodah zarah clothes that they took from the spoils of war.
Kli Yakar teaches that there is another lesson in Yaakov's words. He was telling them to discard the yetzer hara that was within their hearts. This is alluded to in Yaakov's words, betochechem asher elohei hanekhar hasiru, "Discard the alien gods that are in your midst." This refers to the yetzer hara, which is betochechem, within your hearts. As it states in Tehillim (81:10) lo yihiyeh becha el zar, "There shall be no foreign god within you," and Chazal (Shabbos 105b) say, "What is the 'foreign god' within man? This is the yetzer hara!"
So, the Kli Yakar explains that hasiru et elohei hanekhar asher betochechem, "Discard the alien gods that are in your midst," means to cleanse one's thoughts, to be clean and pure, and not stemming from the yetzer hara.
After telling them to cleanse their minds, Yaakov told them to cleanse their deeds from all aveiros. This is the meaning of vehachalifu simloteichem, "Change your clothes." This means to have good deeds, and no aveiros. This alludes to (Koheles 9:8) bechol eit yihyu begadecha levanim, "Let your garments always be white." This prepared them to come before Hashem.
The first step for kedushah and taharah is when a person tells himself, "I am holy, and therefore, I don't want to be among people who don't have yiras Shamayim. I don't want to become tamei with those who are metzora and zav (alluding to people who lack fear of heaven). Also, I don't want to go to places where the guidelines of kedushah aren't upheld."