In my observation, this change is a recent epiphenomenon that is tied to the widespread organizational deployment of learning management systems (LMS).
Thirty years ago, course notes were not generally online, because even in leading universities the Internet hadn't taken hold sufficiently yet. You got your lecture notes on paper, typically by picking up handouts at the classroom door each lecture or by going to a university office and buying a cheaply bound booklet of such notes at the beginning of the semester.
Twenty years ago, it was easy to set up a course webpage and point students to it, but most universities had ad-hoc systems not designed for online course management. This meant that professors could stop worrying about handouts and start sticking a PDF online on a course webpage. The professor generally put that webpage together themselves, and restricting access to material they posted would take a lot of extra work. These was no real incentive for a professor to put in that effort, and thus a large volume of class notes became freely accessible to the general public as a side effect.
Class notes are only one part of the story, however, and a good LMS also helps a professor with managing and reporting assignments, tests, and grades (which can be a big benefit both to individual professors and to universities overall). In most systems, these materials are considered confidential information and must be protected. Thus, any material posted in an LMS is restricted by default. As a result a professor now needs to explicitly decide that they want to post material openly and take extra steps to do so, including considering all of the concerns that have been raised in other answers.
Bottom line: widespread freely accessible lecture notes were a temporary side effect of the technological transition to online course material.