Now that we have discussed why it is necessary to prevent cheating in the classroom we ought to address the next important matter on the subject: why does a student cheat? One factor chiefly figures in determining whether a student will cheat, namely, whether it is easier than the alternatives.
Yes, before you ask, many kids find cheating abhorrent. They have been well raised and I have been honored to teach many such students. Of those who will cheat, some are devious and immoral and others simply succumb to despair and temptation. The former will always consider cheating a possible option and the latter will weigh with greater care to see if it is a viable alternative.
The first and most infamous of those alternatives is failing and needing to attend summer school. Don't underestimate how many summer school programs know this and make short and easy, and thus popular, summer courses. Those courses make failing a class a serious option for kids whose parents can afford it. For many though, the embarrassment and inconvenience of summer school is a deterrent.
The next alternative is the penalty for cheating. If either the amount of effort it would take to get away with cheating or the penalty for getting caught, which includes becoming known as a cheater, are too high, many students will reconsider trying to cheat. I say many and not most because cheaters are notorious for spending such amounts of time on ludicrous methods of cheating that it would have been easier simply to learn the material. Yet they may be tempted if left the opportunity.
If you are known not to care or if the administration is known to not support teachers' policies, cheaters have the opportunity. If you are known to police cheating but they think they can get away with it when, say, someone else proctors your midterm, cheaters have the opportunity. If you give a lot of work to be completed at home, that's their opportunity. If you don't evaluate assignments in detail, that's their opportunity. If you park yourself at your desk and browse the internet when you give tests, which is sadly very common, that's their opportunity.
The final alternative is learning the material. Because some classes and teachers are so bad it is necessary to say one thing bluntly: don't make your class such a mess that the students are bewildered and, having no idea what's going on, grow desperate to pass and turn to cheating. If I hadn't seen it, I wouldn't say it.
Worse is that many of those bad teachers know their classes are disasters and instead of making improvements, simply make the classes so easy that no one can fail. Administrators often know this too but don't care because they don't get complaints from parents, and they don't get complaints because parents rarely complain about anything besides failures. It is easy to see a kid caught in a dilemma between parents and teachers who should know better.
Most students who cheat, however, simply find themselves in hot water and then see cheating as a way out. Such is why students tend to cheat a few weeks before the end of a marking period or before some kind of evaluation is sent home to parents, that is, they cheat when they realize they are doing poorly but there is not enough time to learn the material. At that time, kids get desperate; so tell them often how they are doing. Teachers are notorious for not posting grades, not giving work back, and not being clear and objective about how students are doing. What's a kid supposed to do? So tell them, either verbally, with evaluations, or with progress reports, but tell them. It's part of the job: help them learn and help them know that they are learning.
In conclusion, make that learning the most attractive option. There are enough natural barriers to learning such as the difficulty of the material, student ability, and the vicissitudes of life, so as obvious as it sounds: do everything you can to facilitate learning. Have such quantity, quality, and variety in your teaching and evaluating that cheating becomes unnecessary. Be so persuasive and enthusiastic that cheating becomes unattractive.
The more attention you give to teaching, the less you will have to give to the problem of cheating. The situation is as with lawns: the best defense against weeds is healthy turf. You'll never be able to drive cheating out completely, but you can create an atmosphere in which it cannot thrive.