EDIT: Modifying the numbers to what's currently known as this comes up as a Google result. Where it says '40mA' now, it used to say '12mA' as the datasheet at the time said '12mA'. Sorry if that makes this post a bit odd when taken into account what's said in the rest of the thread.
The 40mA *is* the maximum amount of current you can safely pull from the ESP32 [2]. A real chip actually can deliver much more: feel free to try it by making a pin high and using a multimeter in mA mode to measure the current to ground. (Not for too long, as I said, in theory it can damage the chip, although a few seconds probably won't harm.) You'll probably measure a current of 50mA'ish. Pull this current for too long, however, and you risk damaging the pad driver.
"Drive strength", when talking about VLSIs and digital logic, actually has a pretty narrow meaning: it relates to the fanout of a chip, which essentially is how many digital inputs you can drive from it [1]. The problem is that if you have a drive strength that is very low, the parasitic capacitance inherent in the input pins can take a while to charge. This leads to issues when you output e.g. a high-frequency clock signal: when you output a clock pulse (L->H->L), your clock signal has gone low again before the signal level on your output pin, slowed down because it has to charge the parasitic capacitance, has raised enough to indicate a high level. You want to raise the drive strength in this case: setting it to 80mA means that
for the short while that the parasitic capacitance needs to charge, the pin can deliver 80mA. [3]
Now, why would we then make the drive strength adjustable instead of keeping it at max all the time? That has something to do with impedances. If the parasitic capacity is very low, or there's a parasitic inductance as well, driving a pin high as fast as possible can lead to overshoot and ringing and nasty EMI-related side effects. That is why you can set it per pin to whatever you need.
So concluding: the ESP32 can drive 40mA or so on an output pin. You can modify the drive strength of the pin in software if the output impedance gives you issues with AC signals, but do not assume this sets the DC current.
[1]: It's actually somewhat more complex than that, but as far as I know, fanout is the reason they came up with a number for this.
[2]: I see now that there has a very recent change in the datasheet that changes a value called 'Imax', or 'Maximum drive strength' from 12 to 80mA, seemingly replacing any value for DC current. I will look into getting this cleared up or corrected, but I highly doubt our analog team decided the ESP32 pins can drive a DC current of 80mA now. EDIT: It's cleared up, the current datasheet currently gives 40mA as the max number.
[3]: For a slightly more experimental approach to understanding drive strengths, see
http://www.thebox.myzen.co.uk/Raspberry ... tputs.html. It relates to the Raspberry Pi so the values are different and I'm not 100% sure if our pad drivers work in exactly the same way, but it may help to give you some intuition for this stuff.