How do I respond to a review of the wrong version of my paper?
Consider the pragmatic approach to this issue: you have already revised the paper according the reviewer’s suggestions, so only the response needs to be worked on. (Apart from other comments orthogonal to this main issue.)

Given that you already called the attention of the editor on the problem and he did not follow up on it, you clearly need to weigh carefully your response (unless you want to pick up a fight). I would suggest that you write a very detailed response letter, in which you explain how the manuscript addresses the reviewer's comments and questions. Do it point by point, quoting all the parts of your manuscript that are relevant (and locating them: page and line numbers).

Just do so by being slightly evasive about the exact evolution of the manuscript. Where you would normally say “we have added a paragraph at the end of section B”, just say “the revised manuscript includes a paragraph addressing the reviewer's question at the end of section B”. It's not untrue, though it is not perfectly clear.



Also, consider going for another journal. If you believe the editor has been treating somewhat badly, you might want to just let it drop and submit somewhere else. It's a complex decision.



Or, if you think it's worth it: make a stand for it. Appeal the editor's decision to the editor in chief, on the basis that a factual error was made. You need to be both strong and diplomatic in your appeal, and back it up heavily with facts. It will be easier if the incriminated review actually quotes some text that has changed in your revised manuscript, in which case the error is evident.