Why should the smallest bypass capacitor be placed nearest to the IC?

Because inductive impedance increases with frequency $$Z=j\cdot2\cdot\pi\cdot f\cdot L$$ you need to have lowest inductance (=shortest trace) for highest frequency filtering.


The traces are the reason why and the parasitic inductance, copper adds inductance, and it can be calculated with the equations below OR you can find a PCB trace calculator.

You then can take the calculated value of the inductance of the copper and plug it into a RLC calculator and find the filter pole

Another factor is the small amount of resistance that traces have, but it doesn't affect the pole of the filter as much as the inductance because it is so small.

The inductance of the copper (usually in nH for small traces around 8mil wide and short) makes a filter with the capacitor which will cause resonance and block the current source from the capacitor, this happens at high frequencies, but with IC's that run in the 100MHz or GHZ it can be a problem.

An easier thing than calculating is not calculate the filter pole and just place capacitor with the smallest value close to the IC.

enter image description here
Source: https://www.eetimes.com/power-tip-56-estimate-pwb-interconnect-inductance/#