Why is the ROC curve of a random classifier the line $\text{FPR}=\text{TPR}$? The title is my whole question.  FPR is the false positive rate. TPR is the true positive rate.
 A: If you classify a fraction $k$ of your cases as positive then, because of the randomness, the same fraction $k$ of cases which should be positive will be classified positive (true positives), and the same fraction $k$ of cases which should be negative will be classified positive (false positives). 
So the true positive rate and the false positive rate are the same.
A: Identity
Let $T$ be the event that a case is positive, and $R$ the event a case is predicted to be positive by a classifier.
Since $T$ and $T^c$ are mutually exclusive and collectively exhaustive, we can decompose $\mathbb{P}(R)$ as follows:
\begin{split}
\mathbb{P}(R) & = \mathbb{P}(R|T)\mathbb{P}(T)+\mathbb{P}(R|T^c)\mathbb{P}(T^c)\\
 & = \mathbb{P}(R|T)(1-\mathbb{P}(T^c))+\mathbb{P}(R|T^c)\mathbb{P}(T^c)\\
& = [\mathbb{P}(R|T^c)-\mathbb{P}(R|T)]\mathbb{P}(T^c)+\mathbb{P}(R|T).
\end{split}
The identity
$$\mathbb{P}(R)-\mathbb{P}(R|T) = [\mathbb{P}(R|T^c)-\mathbb{P}(R|T)]\mathbb{P}(T^c),$$
means that $\mathbb{P}(R)-\mathbb{P}(R|T) = 0$ if and only if $\mathbb{P}(R|T^c)-\mathbb{P}(R|T)=0$, for $\mathbb{P}(T^c)>0$.
Random guessing
To begin, inspect the left-hand side condition: $\mathbb{P}(R)=\mathbb{P}(R|T)$. This condition implies the independence between events $R$ and $T$. A classifier that is based on random guessing has to satisfy this condition.
Suppose the classifier is random guessing but it does not satisfy the left-hand side condition, i.e. $\mathbb{P}(R)\ne\mathbb{P}(R|T)$. Then, the guesses are biased for cases that are in $T$, i.e. the classifier guesses differently when encountering a positive case. This contradicts the notion of a random guess.
In other words, if the classifier is random guessing unconditionally, or conditionally on positive cases, it should perform equally well in both cases.
Line y = x
Next, inspect the right-hand side condition: $\mathbb{P}(R|T)=\mathbb{P}(R|T^c)$. This condition means that the true-positive rate equals to the false-positive rate. Geometrically, the line $y=x$ on the ROC graph represents this right-hand side condition. This is because, the ROC graph y-axis and x-axis represent the true-positive rate and false-positive rate respectively.
Equivalance
To conclude, the left-hand side condition represents a random-guessing classifier, and the right-hand side condition represents the line $y=x$. They are in fact equivalent.
A: A general classifier produces a point in the ROC space rather than a curve.
In order to consider a curve you typically further assume a parameterized classifier class of the form $f_t(X) = \mathbb{1}[h(X)>t]$, where $h(X)$ is a continuous random variable.
Now $(P(h(X)>t|Y=0),P(h(X)>t|Y=1))$ is a curve in the ROC space (parametrized by t).
In this case and if in addition $h(X)$ is independent of $Y$ then
$$P(h(X)>t | Y=1) = P(h(X)>t) = P(h(X)>t|Y=0)$$
and the curve is the line $(P(h(X)>t),P(h(X)>t))$.
