Is there a better counter-example? (problem involving limit of composition of functions) This question arises from one of the Berkeley Problems in Mathematics, fall 1981. It asks me to find a counterexample to the following claim:

Suppose $\lim\limits_{x\rightarrow x_{0}}f(x)=a$, $\lim\limits_{t\rightarrow a}g(t)=b$, prove or find a counterexample for the claim $\lim\limits_{x\rightarrow x_{0}}g(f(x))=b$. 

I feel this should not be true, for we can select functions with infinite 'singularities' near the origin like $x\sin[1/x]$. Then for each value $x=\frac{2}{k\pi}$ we should have the value to be equal to $x$. But this is not a counterexample. Looking up the book the authors give the following example:

$f=g=1$ when $t\not=0$, $f=g=0$ when $t=0$.

The authors then claimed that $\lim_{x\rightarrow 0}g(f(x))=1$ while $\lim_{t\rightarrow 0}g=0$. Unless I am confused with the definition of the limit, that there exists $\lambda$ such that for any $\epsilon$, if $|x-x_{0}|\le \lambda$, then $f(x)-A|\le \epsilon$, I do not see why $\lim_{t\rightarrow 0}g=0$ since $t=0$ is a removable singularity for $g$. So assuming I am wrong somewhere, I want to ask:

1): why the limit of $g$ at 0 is 0?

2): is there better counterexamples?
I think you just made a careless error. In the example provided, the limit of $g$ at 0 is not 0; it is 1, as you said. Here $x_0 = 0$, so that $a = 1$. So lim$_{t\rightarrow a}{g(t)}$ = lim$_{t\rightarrow 1}{g(t)} = 0$. And lim$_{x\rightarrow x_0}{g(f(x))} = $ lim$_{x\rightarrow 0}{g(f(x))} = 1$. This is probably as simple a counterexample as one could hope for.
Another counter-example that would be more familiar to a college or high-school calculus student would be the following. 
consider $f,g: \mathbb{R} \to \mathbb{R}$ defined 

$$
\begin{array}{ll}
g(x) = \frac{x^2 -1}{x-1} = \frac{(x+1)(x-1)}{x-1} \text{and}\\ 
f(x) = 1. 
\end{array}
$$

Then 
$$
\lim_{x \to 1} g(x) = \lim_{\epsilon \to 0} \frac{(1 + \epsilon +1)(1 + \epsilon-1)}{1+ \epsilon -1} = \lim_{\epsilon \to 0} \frac{(1 + \epsilon +1)(\epsilon)}{\epsilon} = 2.
$$

However
$$
\lim_{x \to 1}g(f(x)) = \lim_{x \to 1}g(1) = \frac{0}{0},
$$
which is undefined.

So we need that $f(x) \neq \lim_{x \to x_0} = a$ on a small interval $(x_0 -\epsilon, x_0 + \epsilon)$ containing $x_0$ to avoid problems (How to prove this limit composition theorem?).

The counter example in the text likely meant to say $f$ is identically 0 and $g(x)= 1$ for $x \neq 0$ and $g(0) = 0$. Hopefully you can see the parallel between this example and my own. When $f(x)$ is constant around $x_0$ then the limit of $g$ is forced to equal $g(f(x_0))$. 

There may be a typo in your textbook. This is very common, and it is important to do a common sense check on math problems and "read" what the author meant to say rather than the exact words on the page.