There are three general reasons Lear mistakes Tom for a philosopher.
The most basic you've mentioned: Lear has lost his grip on reality.
However, the second is quite sad: the things this madman says ring true with Lear's current experience. He (Lear) wishes he could "prevent the fiend and kill vermin," and he speaks directly and honestly about his suffering, which those around Lear can't do.
The third is more symbolic: the play has entered a stage when madmen seem more on target regarding the world than the sane and noble.