For sake of argument, consider that skill of a topic is spectrum from "new and learner" to "experienced and expert." Where should you relatively be in order to teach the topic effectively so that your students could do well in the long run?
Omitting the situation where the student is more knowledgeable of the subject that the teacher themself, take the example where the teacher is more or less at the same level of the student. They would seem unprepared when a student asks a question that is beyond the scope of that current lesson or a question that demands more than a "Wikipedia-level" familiarity of the subject.
Then again, take the other extreme where one could be a PhD in number theory but teaching addition to kindergarten. Let's assume that this person is also good with young kids and is effective with primary school education, I think it's safe to say that being so advanced is overkill.
So if we say the teacher is more skilled in the topic than the student, the question becomes how much more skilled? For example, could a pre-calculus teacher effectively teach the subject thoroughly without not knowing measure theory? It seems very possible (and is probably overwhelmingly common). In fact, they could probably not know analysis and still teach well. But could a pre-calculus teacher not know calculus?
If we consider post-secondary teachers at colleges and universities as standard, they generally have a PhDs and they often teach 1st year courses. In the spectrum of Baccalaureate-Masters-Doctorate, then it seems that it's 2 "degrees" ahead is what's necessary?