Near x=0, both ex−1 and x are tiny, so xex−1 looks like a tiny number over a tiny number, which could be anything. What matters is how fast each one shrinks. Zoom in on the graphs and each looks like its tangent line at 0: ex−1≈1⋅x, and x is exactly 1⋅x. Their ratio is then about the ratio of their slopes, 11=1. That is L'Hopital's rule: when top and bottom both head to 0, their ratio approaches the ratio of their derivatives.
The same idea works for ∞∞. As x→∞, both parts of exx2 grow without bound. Apply the rule twice: ex2x, then ex2→0. So ex outgrows x2, and repeating the argument shows it outgrows every power of x. Each round needs its own check that the form is still 00 or ∞∞.
The rule applies only to those two forms. For x+1cosx at x=0, substitution gives 11=1 at once; differentiating anyway gives 1−sinx→0, a wrong answer. For xx+1 at 0 the form is 01, so the function blows up, yet the derivatives 11 would wrongly suggest 1. And L'Hopital is not the quotient rule: you differentiate f and g separately, never the fraction gf as a whole.
Think of it like this. Two runners leave the same line at the same instant. A moment later both are barely past it, so comparing their distances directly is hopeless, but the ratio of their distances is about the ratio of their speeds. That is the rule for 00. The comparison only makes sense if both really started together at zero.
Core idea. For an indeterminate 00 or ∞∞ limit, replace it with the limit of the ratio of derivatives.