Look at the datasheet for the 2N2222A and under "On Characteristics" "DC Current Gain" look at the range of h
FE (current gain). At very light loads it can be as low as 35 and at high loads it could be as high as 300. Even at 10 mA (and we're talking about 20 mA), the gain could be as low as 35 (at a very cold -55 degrees C) up to 75.
ETA: I guess I should mention that collector current is equal to h
FE * base current. The whole discussion is meaningless without this definition.
Gain is all over the map and while 1/10 base current is overkill, it is used fairly often. Remember, we assumed the driving voltage was 5V but what if the driving device can't quite reach 5V? There are logic families where the output voltage is somewhat less than Vcc. Our circuit still has to work regardless of what the driving device is doing and regardless of which gain 'bin' our transistor came from.
While you're at it, look at V
CE(sat) I assumed 0.2V and the datasheet says a max of 0.3V but they don't specify a 'typical' value.
Then look at V
BE(sat) - I assumed 0.7V but the real value could go as high as 1.2V and that changes the calculation substantially.
Don't like 10% base current? No problem! Pick a different number. But what you can't do is design a circuit that is dependent on selecting transistors on the basis of gain from a box of parts. What if you happened to grab a 2N3904 - no, I haven't looked at the difference, I just assumed a 2N2222A for this discussion.
https://www.onsemi.com/pdf/datasheet/p2n2222a-d.pdfSince we're only talking about 20 mA of collector current and 2 mA of base current (maybe), the 1/10 thing works pretty well. Even if all the parameters stack against the design, the base current will probably be adequate.
The only thing that really matters is how the circuit performs with real numbers. I used 2V for Vf of the LED - it could be as high as 3V at 20 mA according to this typical LED datasheet. Look under "Forward Voltage".
https://www.vishay.com/docs/83171/tlur640.pdfUnderstand that every single number I used was a guess. But there's a reason that datasheets have a lot of numbers. Oddly, under different circumstances, every single number on the datasheet is important.
As I said earlier, build the circuit on a breadboard. Measure V
be, I
b (measure drop across the base resistor and calculate - measure the resistor first so you have the real number), measure Ic (measure drop across the collector resistor and calculate) and, most important, measure V
ce(sat) by probing between collector and emitter. Is the transistor saturated?
Measure Vin so you can see what the driving circuit is doing. If this is coming from a uC, use an output pin to drive the base resistor.
Having completed this experiment, you will understand why we commonly guess at 1/10. It's a guess that is known to work more often than not and when you're talking about 2 mA, it probably doesn't matter unless you are using really wimpy batteries. Then you are probably wasting energy but think about it: you are wasting 10 times as much lighting up the LED. Pulse it slowly 1/10 on and 9/10 off - this will reduce the energy consumption dramatically.