When asking a question of identity or choice, use 'which' when there are a relatively limited number of options ('Which was your favorite wife, your first one or your second one?') and use 'what' when there are a relatively wide range of options ('What colour car are you going to buy?').
If I had a thousand and one wives, wouldn't it still be which wife is my favorite?
This question reminds of the "how much" versus "how many" puzzle . I rationalize the much vs many as one where it depends on whether something is countable or not: