Why did Jesus wash Judas' feet knowing his heart had turned bad? Well Jesus models for us here how we are not to practice presumptive excommunication. Jesus treated Judas as his own, in order to show the need to leave time and opportunity for repentance and turning. The wheat and tares will grow up together, and we are not to be presumptuous about who the tares might be, but to be longsuffering with one another.
It does not mean Judas at that time was forgiven or saved in that moment. Jesus made it clear that one of them was a devil and that one of them was going to betray him. Which is what happened. Judas betrayed the Lord. He then went and hung himself. A sin that cannot be repented of (Unless one comes back from the dead).
Source Used:
Jesus Washes Judas’ Feet – A Lesson In Humility (via Ligonier Blog) | mgpcpastor's blog