In the distant past the Hofbräuhaus used to number their steins. According to Walter Mück, who has written a book on Munich brewery steins (" Historische Bierkrüge Münchner Brauereien" which you can buy on his site), the numbers on the lid were to keep track of the inventory of steins. If a stein got broken, which many did they would issue a new stein with the number, or if they needed more inventory they would make a new range of numbers. His insight explains why you may see a very low number on what is obviously a newer stein than some with higher numbers that are clearly older. Steins with a particular number may have been broken several times and replaced over and over in the inventory. I would imagine also that the numbers would help the people serving the beer, identify which customer had which stein. The highest number on a stein that I have encountered is # 28,670.
At some point, the Hofbräuhaus made numbered steins available for purchase, as well as using them strictly for inventory. The evidence that suggests this is that a few numbered steins have surfaced that have original sales receipts. I imagine that once a stein was sold, that particular number would be out of circulation and would not be remade. The earliest HB stein with it's original receipt dates from 1898. Ron Gray the owner of the stein wrote and artiucle about it. The link to the article is http://www.steincollectors.org/steinmo/2004/HB.html. The latest one I have come across is dated from 1914. That means for at least 16 years numbered steins were available for purchase. It is unknown whether or not there was a certain criteria to able to purchase your own numbered stein. Perhaps they were only sold to regular longtime patrons (like the stein lockers there today), or maybe there was no restriction and anyone was able to purchase them. I am yet to see in over 100 numbered steins, a duplicate. That doesn't mean there isn't any, with close to 30,000 numbers having been issued. There is no archive at the Hofbräuhaus anymore, so many of the questions that could have easily been answered at this time cannot be.
If you have a numbered HB Stein, I have compiled an HB Stein Registry that is cataloguing numbered HB steins. The registry is sent out each month to those that contribute.
Below is pictured the HB stein in my own collection that still has the receipt. It was purchased in 1912.