When does L' Hopital's rule fail?
Solution 1:
Even for analytical functions, this kind of thing can happen.
Consider $\displaystyle\lim_{x \to \infty}\dfrac{e^{x}-e^{-x}}{e^{x}+e^{-x}}$.
Blindly applying L'Hopital's Rule repeatedly gives: $\displaystyle\lim_{x \to \infty}\dfrac{e^{x}-e^{-x}}{e^{x}+e^{-x}} = \lim_{x \to \infty}\dfrac{e^{x}+e^{-x}}{e^{x}-e^{-x}} = \lim_{x \to \infty}\dfrac{e^{x}-e^{-x}}{e^{x}+e^{-x}} = \cdots$.
But if we divide the numerator and denominator by $e^x$ we get: $\displaystyle\lim_{x \to \infty}\dfrac{e^{x}-e^{-x}}{e^{x}+e^{-x}} = \lim_{x \to \infty}\dfrac{1-e^{-2x}}{1+e^{-2x}} = \dfrac{1+0}{1+0} = 1$.
Also, consider $\displaystyle\lim_{x \to 0^+}x \ln x = \lim_{x \to 0^+}\dfrac{\ln x}{1/x}$.
Blindly applying L'Hopital's Rule repeatedly gives: $\displaystyle\lim_{x \to 0^+}x \ln x = \lim_{x \to 0^+}\dfrac{\ln x}{1/x} = \lim_{x \to 0^+}\dfrac{1/x}{-1/x^2} = \lim_{x \to 0^+}\dfrac{-1/x^2}{2/x^3} = \lim_{x \to 0^+}\dfrac{2/x^3}{-6/x^4} = \cdots$.
But it we stop after applying L'Hopital's Rule once and simplify stuff, we get: $\displaystyle\lim_{x \to 0^+}x \ln x = \lim_{x \to 0^+}\dfrac{\ln x}{1/x} = \lim_{x \to 0^+}\dfrac{1/x}{-1/x^2} = \lim_{x \to 0^+} -x = 0$.
In both of these problems, the solution was to use basic algebra instead of just L'Hopital's Rule. The techniques taught in introductory calculus will not solve every limit problem in the world, but they will solve the problems encountered in introductory calculus. The important thing for students is to know many techniques and learn to figure out which ones will work for a given problem. Many students learn L'Hopital's Rule and then forget how to use every other tool. This is why after teaching L'Hopital's Rule, you should throw in a few examples where L'Hopital's Rule fails. This way, they think of L'Hopital's Rule as just another tool instead of magic.
Solution 2:
A priori l'Hospital's rule is not meant to be a magic rule to solve limits ; you can write every limit in the universe as a ratio of two functions, and if these two functions happen to be infinitely-differentiable-non-analytic functions like yours, then applying l'Hospital's rule won't be much of use.
At the introductory calculus level, what is most important for students is not to learn all those rules by heart and throw them on paper (which is useful to get grades, but completely useless outside the classroom for most of them), but rather to use their brains and figure out a solution. I don't think that writing $$ \lim_{x \to 0} \frac{e^{-\frac 1x}}{e^{-\frac 1{x^2}}} $$ by writing it as $e^{\frac 1{x^2} - \frac 1x}$... okay I had a comment about this but it kind of went wrong when I found the trick.
And yes, there will always be issues with such functions ; it could be a good exercise to come up with functions whose limit might exist but be hard to compute.
Hope that helps,