Problems with input leakage current in a microcontroller
how is possible that that current exists if the circuit is open? How can an INPUT pin deliver current to the outside?


Modern MCU pins are very complex. They are configurable by firmware, and contain each and every options that a GPIO is designed for, to be able to change configuration. Below is simplified block diagram for Paspberry Pi GPIO pin:



As one can see, the pin has a connection to OUTPUT buffer (which is logically disabled if the pin is configured as input), then there is pull-up/pull-down resistor with a switch, there are ESD protection with clamping diodes, and there is an input buffer. More, there can be other optional functions as analog ADC inputs or DAC outputs.

All these elements are made of CMOS transistors in complicated configurations, and every transistor does have some leakage. It might be small, but a modern GPIO cell may contain HUNDREDS of transistors, and the external pin might have a dozen of them permanently connected. The combination of leakages is not predictable due to manufacturing variance, and designers work hard to limit the total leakage. This combined leakage can have positive or negative direction (pulls slightly up or down), and is specified in manufacturer's datasheets (example), usually of the order of +-1uA. That's why you need to have some external pull (down or up) which is strong enough to overpower the inherent leakage and have well-defined logic levels.

EXAMPLE: What resistor value is needed to overpower 1uA (I = 10^-6 A) of leakage current down to logic "0" level? Assuming the "safe" logic "0" as 0.5 V, V=I*R, so R = 500k is theoretically sufficient to get any leaky pin to logic "0" over all "corners" of manufacturing process. To be on a very safe side, 100K would be very good. On a practical side one needs to remember though that some "no-clean" water soluble soldering fluxes can overpower 100K if the pin is in close proximity to Vcc, so it might be better to use the mentioned 10K, or/and clean (and bake) the boards thoroughly in production.