IMO, there is no ethical problem with students preparing for a course in advance. As Moriarty notes in their answer, what matters is that the student learns the material, not when or how they learn it.
That said, there are (at least) two actual problems that your question touches upon:
the occasional problem of advanced (or self-taught) students taking beginner-level courses for "easy credits", and
the practical problem of teaching a course for students with a highly variable baseline experience level.
( 5 months ago )
I think this is an unspoken question in academia: how do you factor in the effort put forth by a student before taking your class?
I think the answer to this question has several consequences:
it presents accurate reflection of your teaching,
it presents more accurate reflection of the quality of work of a student
It also addresses a more profound question:
Is good educational outcome measured by grades a product of privilege or a measure of intelligence?
In my undergrad classes, I find for some courses the class will be divided into two camps - one who has done some work outside of the class (the ones who have a background), another who will try to learn the course material as the course progresses.
The results are vastly different. The ones who have done work outside of class will achieve higher grade across the board, are more motivated, ask extremely technical questions in classes, gets all the attention of the professor as the next "rising star", etc., whereas the other students who haven't had as much experience prior coming to class will try his/her hardest with uncertain outcomes and will tend to struggle a great deal more.
From my own observation, a course taught by a lecturer who uses less conventional course material seems to even out the grade much better than a lecturer who uses standard material - since in these cases, the advanced students are less able to predict what will show up on the exams.
This is most significant in computer science classes. Any computer, CS, programming classes will teach things in two folds: practical and theoretical. I find in many of my classes, a portion of the student will have a great deal of knowledge in the former, therefore significantly reducing his/her course load. How easy is it to ace an introduction to programming course if you already have years of experience in the language? These courses will always produce several students who go on doing interesting research or work at some big-name companies, and the lecturer will be praised as being effective at teaching. But it is so obvious to me, that the student - the one who has taken years of programming at middle to high school level, a summer course at another University... - is more advantaged in this area than a student who is just coming in to be acquainted with a field of study.
Hence, what is the ethics of preparing yourself for a course before it begins given such uneven playing field in today's academic setting? Will this be a mark of a motivated student who is genuinely interested to learn a subject or a student who is just trying to get ahead and earn good grades? Why should or shouldn't a student prepare himself for all the courses he will take one or two years down the road?