Not much to add to other answers. They were basically numbered in the order they were first manufactured - don't forget the 707. The 717 was omitted from that list, and pencilled in later as a kind of successor to the MD80 series taken over when Boeing took over McDonnell Douglas. Why those numbers? Well, why not? Why 8086, 80286 etc?
Boeing (and, for that matter, Airbus) tend to number variants of the main type in -100's. So the first Boeing 747 was the 747-100, the second was the -200 ... up to the -400, which is the most recent. These numbers aren't linked to number of passengers (in any case, the number of passengers in an airliner depends upon how it is fitted out - there are -400's which are only set up to carry a few people). It is just an index. The Airbus A340 goes up to the 340-600.
Also, not all variants are covered in this scheme. The ugly 747 SP doesn't follow the pattern. That's the short, stubby one with the tail that tapers away.