I can only add a bit to the excellent answer of OBu. While the question is largely philosophical there are a few things that can be done.
First, it must be possible for a student to fail. Otherwise they have little incentive to engage with the material. They are busy and have a lot of requirements to balance, so it isn't good, even (especially) for them, to make it too easy.
Second, it must be possible for every accepted student to excel. If that isn't true at your university, you need to try to find a way to change the system. You can change it by adjusting admission requirements or by changing the educational system itself. As a professor, you probably have more influence over the latter and you have complete authority in your own courses. If you don't, then you have a deeper problem. For example, if your Dean requires you to fail a certain number of students then there are ethical issues around your participation.
However, not every student can be expected to succeed with the same amount of effort. Some things are hard and and they are harder for some than for others. You may need to find a way to support and require that harder effort from some who would otherwise fall behind. Mentoring helps, but so does something as simple as making additional work possible.
However, in the modern world, you may have to do more than teach your subject effectively. I learned that students come to university unprepared to learn. No one taught them how to learn and so they were very ineffective at it. So my job became, for a subset of students, not only to teach them CS, but to teach them how to learn CS.
For example, they were initially ineffective note takers, if they bothered at all. So I wound up teaching them how to take notes (by hand) and to summarize them. It doesn't need to take up a lot of time in class, but a couple of minutes at the end, asking individuals to tell me the most important lesson of the day can work wonders.
Also, it turns out that group/team work is a big win, both for the strugglers and for the superstars. But you need to organize it in a way that the superstars don't do all the work while the others watch, or even avoid participation. This may require using a flipped classroom in which you can participate in the interactions. If lecture isn't reaching every student, then you can de-emphasize lecture for more effective teaching (and learning) strategies.
If you are given an impossible situation, say 200 students, then your job becomes managing your (hopefully large) set of TAs, so that students can get the individual help that you can give. If your research load is so big that you can't do that, then don't take on such courses, as hard as that can be to arrange. But don't participate in a situation that you know guarantees failure. Every student should be able to succeed through their own efforts. But you can't ignore the realities of the students you have in front of you.
I once had a pair of students who, I think, had never had a positive educational experience. The faculty thought them pretty dull. The course was advanced and both had previously failed it. But they decided that they would pass this time and worked as a team to do so, studying a lot on their own and formulating a ridiculous number of questions for me. Most of my office hours that term were with these two. Neither of them was a quick learner so I got the same questions over and over. However, one incident toward the end of the course stands out. The three of us were in my office and one of them asked a question. I had just opened my mouth to start explaining, when one of them said, "No, let us try to explain it to you." They did and did so correctly. They wound up with the two highest grades in the course that term though the competition was pretty much loaded with superstars. I was accused by a couple of the superstars of bringing in a ringer to make them look bad. But hard work and desire on their part and patience on mine made the difference.
Let me give, also, a grading technique that can work effectively, though in some environments it would be forbidden, as it permits everyone to get the highest marks if they are willing to do the work. It is called Cumulative Grading. The idea is to have a total number of points for a course, say 1000. There are a lot of tasks required in the course and each is pre-assigned a point total for contribution to their personal goal. Each task is graded in the usual way and a point total is assigned to it. If the points available for a task is, say, 20, then they might get 17, for example. When their total reaches a certain level, they get a certain grade, say 900 points is an A level. The other feature of this is that exams counted for relatively little (around 300 total of 1000) and projects counted for more, including team projects. Finally, I let students resubmit work for regrading and the student could make up part, but not all, of the deficit they had on the first round, provided that the first round was submitted in a timely fashion. Sloppy first versions were discouraged from the fact that you could only earn back a certain percentage of the points lost in the first version. Each version submitted was returned with a point total as well as comments for improvement.
The scheme above gives the struggling student the opportunity to improve by doing additional work (on the original assignment), improving it at my direction. The superstars didn't participate in this as they did fine originally, but if they had a oopsie on an assignment, they could still fix it.
A caveat, of course, is that I taught small classes (30 or less), though I had a wide range of "abilities" among the students. Note also, that for a student who found the course fairly easy and who had other commitments, he or she could simply stop trying hard once they had achieved their desired number of points for the grade they wanted. Usually those students are going to learn no matter what you do, so I never thought of that as a problem. But for some students, simply passing is their goal, and it allowed them to know when they had done so in a fairly risk free manner.
You can balance this out. For what it is worth, even though using a "permissive" grading structure, my reputation among the students was that I was "very demanding".