The problem is that cramming for an exam does not seem to promote retention. Knowledge gained through cramming follows a sharp peak that drops off steeply on both sides. If that's bad, then why don't we see more exams that are given at some random time? Instead of "the exam will be given on day t," why not "the exam will be given randomly on one of these 3 dates"? If retention really is better accomplished by not cramming, then in fact spreading the possibility of testing over a few weeks may actually make it worth learning the material more deeply, rather than just cramming repeatedly.This is an interesting observation about the learning-by-cramming process. Students do not retain much if cramming is their method of preparation. In my experience, too many students cram, rather than smooth learning over time. As Xan points out, maybe randomized testing dates would give the crammers the better incentives for real learning.
Then again, the problem with cramming isn't just the timing of studying, but also its content. To cram, a student masters replicating material by rote, rather than cultivating a deep understanding of the concept. Rote memorization is easier while understanding is more rewarding. As a result, extrinsic motivation is better at getting people to memorize whereas intrinsic motivation is better at getting people to go for deep understanding.
Wanting to do well on the exam is a natural impulse, but this impulse is also extrinsic. For this reason, I expect that there will always be cramming as long as there are exams. But, there will be less cramming for the exam on topics that were motivated really well intrinsically. For the same reason, there will be less cramming done by "good" students because they are the ones who are beacons of intrinsic motivation.