There is some evidence of positions being referred to by number - similar to baseball's scoring system - prior to this, but nothing is documented well. Related to this, when the Yankees started using uniform numbers, they were numbered by their order in the batting lineup (Ruth #3, Gehrig #4, et cetera).
Since, in the old days, it was customary for all players to play the entire game, this system made sense, and it was not until substitutions became prevalent that the idea of additional numbers became necessary.
Occassionally back in the day, players other than the goaltender would wear #1 - when George Hainsworth set the NHL record for single-season shutouts, he wore #10, and his defenseman Herb Gardiner wore #1. At this time, some goaltenders took the highest number on the team because they were the last line of defense. Hainsworth also wore #12 for at least one season, while Davey Kerr wore #15 and Jack Norris wore #17.
When it was not required for teams to dress more than one netminders, it was customary for multiple goaltenders to wear the same #1 over the course of a season - and, in fact, more than one time a goaltender was replaced due to injury, and the new goalie wore the same number.
It was not until it became commonplace (and then required) for teams to dress two goaltenders per game that the number thirty gained prominence in the league. Toronto, with Johnny Bower (#1) and Terry Sawchuk (first #24, and the next year #30) were the first to make this permanent. Numbers in the thirties were seen as "safe" for goaltenders, since most numbers below thirty were already spoken for by forwards and defensemen (remember that "high numbers" were essentially-unheard of at this time).
It's possible that #30 itself became popular because so many goaltenders grew up watching the Maple Leafs and saw Sawchuk's number as a viable option. Other numbers that became popular due to who wore them: Gilles Meloche was the first goaltender to wear #27, while Tony Esposito was the first to wear #35. In Montreal, Rogie Vachon wore #29 before Ken Dryden.
#20 is gaining impact with netminders - most prominently, Ed Belfour and Evgeni Nabokov - due to Vladislav Tretiak's wearing the number in his heyday.
Lately, non-traditional numbers have gained in popularity amongst National Hockey League goaltenders. Corey Crawford wears #50 in Chicago, Kevin Poulin and Jose Theodore both wear #60, and Sergei Bobrovsky wears #72 in Columbus. Kevin Weekes wore #80 for much of his career, since it was the closest to #00 that he could find, and Ilya Bryzgalov currently wears #80 for the Oilers (Bryz was born in 1980). Tomas Vokoun wears #92 with the Penguins, since his customary #29 was already taken by Marc-Andre Fleury.
NHL goaltenders are currently prohibited from wearing #0 and #00 due to problems with how the numbers are used in the league's game software. John Davidson switched to the number for the 1977-78 season with the New York Rangers, but returned to his more-familiar #30 after a tough year. Martin Biron was the last NHL netminder to wear #00 in a three-game callup with the Sabres shortly after Christmas, 1995. The French translation of "Biron" is "two circles".
As a final note, Patrick Roy wore #30 up through his entire career, until he reached the Montreal Canadiens. Why did he switch to the now-famous #33? Because tough guy Chris Nilan already wore #30 in Montreal, and when you're a rookie netminder you don't try to get Chris Nilan's sweater number. The rest, as they say, is history.
To The Goaltender Home Page