In an ideal world every tooth on the gear is exactly the same, but in the real world they have slight differences that wear each tooth differently. So by having a prime number of teeth, the teeth of two gears don't mesh with the same teeth on the opposite in a short repeating pattern. The gear teeth wear more evenly this way and imperfections are worn off over time instead of worn in.