Solution to the Klein-Gordon Equation Most textbooks solve the Klein-Gordon equation with the ansatz
$$\varphi(\mathbf{x},t) = \int \frac{\mathrm{d}^3\mathbf{k}}{f(k)}\left(a(\mathbf{k})\, \mathrm{e}^{i k x} + b(\mathbf{k})\,\mathrm{e}^{-i k x} \right)$$
so that they can then choose $f$ so that the integration measure is lorentz-invariant and canonically quantize $a$ and $b$. 
But why is it that we do not instead consider the more natural-looking solution 
$$\varphi(x) = \int \mathrm{d}^4k \, \left(a(k) \, \mathrm{e}^{i k x} + b(k) \, \mathrm{e}^{-i k x}\right)?$$
Is this not a greater set of solutions than the ones expressed at top? I guess this form makes it easier to write down the Hamiltonian (which isn't Lorentz-invariant, like the integrand sans measure of the top equation) but it seems really weird to write down the solution of a Lorentz-invariant equation of motion as a sum over non-Lorentz-invariant solutions and then rescue it with the integration measure.
 A: 
Why do we impose the mass-shell condition at this step and not later steps? If you carry out the standard calculations in a manifestly lorentz-invariant fashion, I find that you get a bunch of $k^2$ you may set equal to $-m^2$ at your leisure.

I'm not sure what you mean.  Note that
$$(\partial_t^2 - \nabla^2 + m^2) \varphi(x) = 0 \implies \int d^4k \left(-k_0^2+|\mathbf{k}|^2 + m^2\right)\phi(k) e^{ikx} = 0$$
from which it follows that $\phi(k) \propto \delta(-k_0^2 + |\mathbf{k}|^2 + m^2)$.   The on-shell condition is imposed by the requirement that $\varphi(x)$ satisfy the KG equation.

But why is it that we do not instead consider the more natural-looking solution [...]

You're free to do that.  However, if you're following the canonical quantization procedure (as opposed to the path integral procedure), then you are only quantizing field operators which already satisfy the KG equation, which means that there's a delta function keeping you on-shell which is hiding in that 4D integral.  Performing the $k_0$ integration makes it explicit. 
Furthermore, if you're working in the Schrödinger picture, then you need time-independent field operators which are going to take the form $\phi(\mathbf{x})=\int d^3 k [\ldots]$, which does not have an obviously Lorentz-invariant measure.  As you say, you can factor out some $f(\mathbf{k})$ to make the invariance explicit, but it's not obvious exactly what $f(\mathbf{k})$ should be.  Starting from the manifestly invariant integral and performing the $k_0$ part leads you to the correct expression for $f(\mathbf{k})$, though you could arrive there from other considerations.
A: Your proposed solution doesn't solve the Klein-Gordon equation. Only Fourier modes in which $k$ is on-shell solve it.
