First, I think that it's crucial to recognise that Harry is a 17 year old that was in the middle of a war, had just died, and met again with someone very dear to him who he had painfully lost. If you think about it, it makes a lot of sense that he would be a little extra affectionate towards Dumbledore, and maybe exaggerate a little bit on the whole "best teacher".
But maybe Harry actually had a reason to say that. You see, in seven years Harry went from a little kid who was weak and bullied, had no idea about what had really happened to his parents, and could never hope to be anything special, to becoming... Well, Harry Potter. And while you might (maybe correctly) argue that Dumbledore was not the most important element behind that transformation, you cannot deny that he was an important one, and a very visible one. The kind of element he would cling to, meaning he would be the person Harry would remember as being the key element on the transformation. The way Harry sees it, Dumbledore took him (even if not directly) from not knowing that there was a wizarding world, to not only knowing it, but being an important part of it.
Finally, if you want a full-on "Harry knew what he was saying", well, throughout the series we see Dumbledore giving Harry advice, and teachings that go beyond the classroom (the kind of thing a private school would be falsely advertising) like not to
"Dwell in dreams and forget to live"
or that
"It is our choices[...] that show what we truly are, far more than our abilities."
Also, in the "Voldemort Classes" Harry does learn about Voldemort, even if little. He learns about Voldemort's history, who he is, what he values, what "hurts him". Things that might seem like we all knew them before hand, but I think we all learned a lot about Voldemort on those classes, and so did Harry. Many strategists will agree that a key point in war is knowing your enemy.
Now, I think anyone of those could explain why Harry would refer to Dumbledore as "the best teacher", but in my opinion (not that it matters), it's a little bit of all of them that lead Harry to make that choice of words.