This is a loaded question, so it's a long post. Until recent years, as two other posters already noted, there was really no logic to the route numbers. Each borough had its own unique numbering system that normally started with a mnemonic letter (B=Brooklyn, BX= Bronx, Q=Queens, M=Manhattan, R=Richmond). This is what I remember from past years:
In Brooklyn route numbers appeared on roll signs beginning with PCC cars in 1936. The older trolleys never saw route numbers but when the buses replaced the trolleys route numbers, already assigned, appeared. All officially had a "B" prefix but often the "B" was omitted - e.g., 35-Church Avenue was officially B35 Church Ave.
In Queens it was similar - but the route number system was applied borough wide to all of the various private bus companies. Often same-company routes were clustered together - e.g., Q6 through Q11 are all Green Bus routes, for example. In 1947 when NYC took over North Shore bus to form today's Queens Division, the old route numbers remained. About twenty years ago "A" suffix numbers on key routes were eliminated for clarity - so the old Q17A became Q30; and Q44A became Q46, etc.
In The Bronx, there was one large private operator, Third Avenue Transit, that converted its routes to bus very quickly after WW II. Route numbers never appeared on trolleys, but did appear on buses. The lower route numbers normally applied to routes that were buses from the beginning and never were trolley routes originally, so that's why BX1/2 is the Grand Concourse route, BX11 is 170th Street, etc. Many Bronx route numbers changed during a wholesale renumbering about twenty years ago.
Staten Island, prior to the current logical system another poster described very well, used very low and very high numbers and nothing in between. R1 through R7, and then R101 through R114 consituted the basic Staten Island local routes prior to the express buses beginning in 1968.
Manhattan's system was the most jumbled because its two biggest private operators (5th Ave. and NYC Omnibus, which were really one company), both used unique numeric only route designators that had no "M" prefix and simply reflected the order of the route's introduction (or in the NYCO case, the order in which buses replaced the NY Railways trolleys in a massive 1935-36 conversion program). To add to the confusion many identically numbered routes operated on parallel avenues - thus Fifth and Madison Aves. each had unique #1 and #2 routes, and Fifth and Sixth Avenues each had unique #5 routes. The Surface Transportation Manhattan routes (formerly Third Avenue Transit) were numbered using "M" numbers after the routes converted from trolley to bus in 1947-48 - and these routes were numbered from M100 through M106. Today's M100, M101, and M104 are the same routes as the old Third Ave. trolleys, with changes as necessary due to one way avenues.
The NYCTA's old Manhattan Division routes, inherited from two small private companies in 1948, were numbered M1, M3, M7, M11, M13, and M15. These routes all operate today, in one case (M11) combined with another former 5th Ave. Coach route; but all except the M15 have different numbers today.
As Manhattan's principal avenues converted to one way traffic between 1948 and 1966, many routes were combined due to the elimination of one direction of travel on certain routes.
In the mid-1970's the Manhattan routes were renumbered to eliminate duplicative and even triplicate numbers, with a M prefix applied to all routes. And as mentioned in another post the crosstown routes were given numbers (up to 116th St.) corresponding to the street they traversed.