It turns out, Clone Wars maestro Dave Filoni was fully aware that explaining this specific plot point was going to be tricky as hell. Rebels established that Rex and two other troopers got around it, claiming they removed their own chips, but we never saw that moment until the big Season 7 finale. The thing is, we never knew how certain Clones (okay, Rex specifically) were able to ignore Order 66. But the animated Star Wars shows, Rebels and The Clone Wars, added a wrinkle to that: Not all the Clones were bad, and a few, managed to figure out a way around their programming. Revenge of the Sith established that all the Clones became Jedi-murderers thanks to one secret code-word implanted in their brains.
Or, at the very least, one specific Clone: Captain Rex. The weird thing is, 15 years after the fact, nobody expected that some of those heroes might turn out to be the Clones. The opening crawl of Revenge of the Sithbizarrely told Star Wars fans there were 'heroes on both sides' of the Clone Wars.