The story
The figurative sense comes from the account in Matthew 27:24 of the Bible in which Pontius Pilate, unwilling to condemn Jesus who has committed no crime but whose crucifixion the crowd has called for, symbolically washes his hands in public and says (according to the King James Version; spelling modernized): “I am innocent of the blood of this just person: see ye to it.” Another literal and figurative usage of the expression can be traced to Deuteronomy 21:6 where the elders of Israel are commanded to "wash their hands" as part of a ceremonial absolution ritual initiated upon the discovery of a corpse outside the jurisdiction of any city.
Etymology from Wiktionary, CC BY-SA 4.0.