Q:

Why is the Riemann integral only defined on compact sets?

Every text I look at says a function must be bounded and be defined on a compact set before one can even think about the Riemann integral. Boundedness makes sense, otherwise the Darboux sums could be undefined. However, I don't see where it becomes important that the integral be taken over a compact set. 

A:

If you use the definition without tagged partitions, the reason the interval needs to be compact is that you need the function to obtain suprema and infima on every subinterval on a partition. For example $f(x) = 1/x$ is continuous on $(0,1)$ (so it should be integrable), but it never attains a supremum in the first subinterval of any partition.
Even if you use tagged partitions, this problem persists. Again, consider $f(x) = 1/x$ on $(0,1)$. Let $P_n$ be a sequence of partitions such that $P_{n+1}$ is a refinement of $P_n$ for all $n$, and let $t_n$ be the tagged point in the first subinterval of $P_n$. Then $t_n \to 0$ as $n \to \infty$. Hence $f(t_n) \to \infty$ so that the limit of $f(t_n)\Delta_1$ will be infinite for partitions whose mesh size tends to $0$ slower than $f(t_n)$ tends to $\infty$. Hence the Riemann sums will not converge to any finite limit which means, by definition, that $f$ is not integrable.
One way to interpret this discussion is that the theorem "If $f$ is continuous on $I$, then $f$ is Riemann integrable on $I$" will no longer be true if we allow non-compact $I$. In fact, this is one of the "deficiencies" that made the Riemann integral unsuitable (along with the more pressing problems regarding convergence for sequences of functions). For Lebesgue integrals, you can use an open set without problems.

