The lecture is not the ideal form of teaching - that is the prolonged one-to-one apprenticeship.
But the lecture has been found to be a very useful form of teaching (for certain purposes, within certain constraints) for many hundreds of years, and it has not been superseded by anything superior.
Indeed, there have been times and places in history when the lecture became the focus for teaching; and some of these times and places have been near the summit of educational excellence; for example medieval Paris or Oxford, of the 'Scottish Enlightenment' universities of the eighteenth century; both of which were lecture-focused systems, although with different forms of lecture.
Indeed, my own experience of the first tow years of medical school was of a lecture-focused system; and this was a very good experience (on the whole).
So, what is the rationale of lecture teaching?
The basis is that the lecture is a one-to-many method of education.
This is appropriate when the teaching has a large 'common' element which it is desired to be imparted to all students. Lectures would be no good if each student was pursuing an utterly different path, nor would they make much sense if all knowledge and understanding was regarded as 'optional'.
The lecture comes into its own as a form when there is a core of knowledge and understanding which it is intended that all of a group of students ought to share.
The lecture begins to break down, and become dysfunctional when there is too great a diversity of people in the class - too wide a range of motivation and ability.
(This break down of the educational process is, however, only apparent when there is a valid and precise method of examination. Otherwise it is easy to fool yourself that 'education is taking place'.)
Even at the best, a lecture can realistically only hope to satisfy about two thirds to three quarters of a class - some will find it too slow and dull, others too fast and difficult.
On any given day, some will be having a bad day (distracted, ill, worried, uninterested, uncomprehending...) and the lecturer may be having a bad day for similar reasons.
The best conditions for lecturing are when (among other pre-requisites) the majority of the class are attentive and want to understand and learn the material being presented; and this best applies when there is a good reason for the class to want to learn the material.
A proximate 'good reason' may be to pass the exams - that is necessary, but artificial; but the best reason (which leads to pressure tending to stimulate the best teaching) is that the class wants to learn the material in order to use it.
This is, indeed, the context for all the best higher and specialized education. Lacking which, teaching almost inevitably gravitates to being 'all about exams' - which pressure leads to inflation of qualifications, erosion of standards, and on a long-term basis allows non-teaching to masquerade as the real thing.