It was originally just 'How do you?' and used as a greeting as far back as the 1400s. In this sense, 'how do you' just means 'in what condition or state are you?' You find the exact same sense in more modern phrases such as 'How are you doing?'...'I'm doing fine' and so on. There is no further question such as 'How am I doing what?' or 'What are you doing fine?'