1. I knew how he did his homework.

2. I knew how he had done his homework.
-----------------------------
What is the difference between the two sentences?

Not much difference at all.

Sentence 2 has more of a finality to it: he did his homework in the past, and he isn't doing homework anymore.

Sentence 1 has a simultaneous quality to it. "I knew" it while he was doing it. (Both in the simple past tense.)