In 1821 Cauchy claimed that the limit of a sequence of continuous functions is continuous. In 1826 Abel gave a complicated trigonometric counterexample. When we teach analysis courses, we usually give the sequence $f_n(x)=x^n$ as a counterexample. Who discovered this counterexample? Why was this counterexample not discovered earlier? I realize that this is a "stupid" question with no simple answer, but every time I teach analysis, this bothers me, so I wanted to see if anybody here could throw some light on this. Thanks in advance!
"Counterexamples" to Cauchy's theorem were "discovered" as soon as he proved it. Of course Cauchy knew all these "counterexamples" but he insisted that his theorem and its proof is correct until his death.
In particular, Fourier's book on heat is full of these counterexamples. Fourier tries to clarify the matter by defining a continuous function as one "whose graph can be drawn without detaching the pencil from the paper". So from Fourier's point of view the curve consisting of the negative $x$-ray, a vertical segment from $(0,0)$ to $(0,1)$ and the horizontal ray from $(0,1)$ to the right, is a graph of a continuous function :-).
I recall that the definition of "function" your are taught in your Calculus class is due to Dirichlet, and this was much later than Cauchy.
Your function which is zero on $[0,1)$ and $1$ at $1$ simply was not a "function" for Cauchy. About the evolution of the notion of "function", read Luzin's paper in the Amer. Math. Monthly.
The problem is that neither the notion of continuous function nor the notion of convergence of functions was sufficiently formalized at that time. If you read Cauchy's proof, it is essentially correct, but he really uses uniform convergence. The notion of uniform convergence was not formalized at that time.
All these things were clarified only at the time of Weierstrass. Nowadays we are all thinking in the framework created by Cantor, so we cannot understand the difficulties experienced by mathematicians before Cantor, Dedekind and Weierstrass. To understand them one has to read the original texts and forget what one was taught in Calculus class.
I'll add to Alexandre's answer that with the way Cauchy thought about continuum and defined convergence, the "counterexamples" did not converge to the limits we ascribe to them today. To Cauchy "points" are "moving points" so he would consider $x=1-1/n$ with variable $n$ going to $\infty$ a "point" infinitesimally close to $1$. But $(1-1/n)^n$ does not converge to $1$, so $x^n$ does not converge to anything at $1$ according to Cauchy. He dismissed Abel's and Fourier's "counterexamples" on the same grounds, see Lakatos, Cauchy and the Continuum.
With Cauchy's "moving points" his "pointwise" convergence turns out to imply Weierstass's uniform convergence. More on Cauchy's understanding of infinitesimals and continuity in Fisher's Cauchy and the Infinitely Small, which also gives a modern reconstruction of Cauchy's argument in terms of non-standard analysis, where it is correct.
Cauchy's formulation of the theorem in 1821 is ambiguous and at any rate in a 1853 article Cauchy seems to state that it was incorrect as stated. On the other hand, in the 1853 article Cauchy modifies the hypotheses and claims that this results in a true theorem, providing a proof thereof. The existence of a correct result (modulo modified hypotheses) could explain why it may not have been obvious that the theorem is incorrect.
Much ink has been spilled on this issue. User Conifold seems to employ Lakatos' terminology who sought to explain Cauchy in terms of so-called "moving points". I personally don't understand what these moving points are, and prefer the explanation given by D. Laugwitz in his 1987 paper in Historia Mathematica here: http://www.sciencedirect.com/science/article/pii/0315086087900450
In his paper Laugwitz emphasizes that he gives an interpretation using Cauchy's own concepts, and that no nonstandard numbers are needed to explain Cauchy, contrary to Fisher cited by User Conifold.
Our recent paper deals with some aspects of this debate: http://dx.doi.org/10.1007/s10699-015-9473-4