ff524 mentions two of the major factors---subfield identification and historical reasons. Even without a rigorous system of subfield identification, there's typically a lot of spacing in course numbers so that unrelated courses don't typically have adjacent numbers (and indeed, there's plenty of space between unrelated courses).
This goes along with numbering sequences sequentially---520 and 521 might form a two course sequence, in which case you don't use 522 or 523 because someone might get confused and think they're part of the sequence. And then later, when you retire 520 and 521 and combine them into a single one semester course, you might call it 522, to remind people it's similar, but you don't use the same number so people can easily tell which course someone took. This leaves a lot of historical detritus (you want to wait a long time before ever using 520 for something new), which leads to lots of widely spaced numbers.