It is often said when someone accuses you of doing something that you haven't done
egFor example:
James: You stole my bank card!
Ruth: No, I didn't. Why would I do that? (it won't work for me because I dont know what your pin code is)
itIt asks for the hypothetical reasons for doing something
- that what could've led him to do that
furthermoreFurthermore, by saying this, the person is making a statement that it is so unlikely of him to do that
butBut what iI don't understand is why do people say why"Why would I do thatthat" instead of why"Why would I have done that?". (as the action was done in the past)