Origin of $\sqrt{-g}$ in the integral of action $S$ I have a question that might (and probably will) be stupid: I do not understand where does the factor $\sqrt{-g}$ (i.e. $\sqrt{-\det\left(g_{\mu\nu}\right)}$) come from in the action integral S when quantum field theory in curved spacetime is formulated.
Many books report things like "use the covariant volume element $\sqrt{-g}dx^{0}dx^{1}dx^{2}dx^{3}$, instead of the usual
volume element $dx^{0}dx^{1}dx^{2}dx^{3}$" but where does this come from?   Is it (and this is the only possible answer I have been able to think about) from the definition of the interval $ds^{2} = g_{\mu\nu}dx^{\mu}dx^{\nu}$?
 A: When you're working in general relativity, the coordinates are basically arbitrary and they do not even need to have dimensions of length. This means that the "usual" volume element,
$$
dx^{0}dx^{1}dx^{2}dx^{3},
$$
as you've called it, is essentially meaningless, since integrals that use this four-volume element will produce different results over different sets of coordinates. Even worse, the physical dimensions of the result will depend on the choice of coordinates.
To fix this, you need an invariant quantity, since the volume element is a scalar. Thus, you need to take the transformation property of the volume element, say,
$$
d\tilde x^{0}d\tilde x^{1}d\tilde x^{2}d\tilde x^{3}
=
J \: dx^{0}dx^{1}dx^{2}dx^{3},
$$
where $J = |\det\mathopen{}\left(\frac{\partial \tilde x}{\partial x}\right)|$ is the Jacobian of the $x\mapsto \tilde x$ transformation, and then multiply it with a factor that will produce the same answer on both sides $-$ i.e., equal objects, which also have identical relationships to the coordinates on either side.
The reason why $\sqrt{-g}$ works to fit this role is because of how it transforms under this coordinate change. It is an important exercise to show that
$$
g = |\det(g_{\mu\nu})| \mapsto \tilde g = |\det(\tilde g_{\mu\nu})| = g/J^2,
$$
i.e. the determinant of the metric over the new coordinates is equal to the determinant of the metric over the old ones divided by the square of the Jacobian of the coordinate transformation (modulo signs, which you should work out by yourself). This means, ultimately, that 
$$
\sqrt{-\tilde g}d\tilde x^{0}d\tilde x^{1}d\tilde x^{2}d\tilde x^{3}
=
\sqrt{-g} dx^{0}dx^{1}dx^{2}dx^{3},
$$
or in other words, that the value of the expression $\sqrt{-g} dx^{0}dx^{1}dx^{2}dx^{3}$ does not depend on what coordinate chart you use to calculate it.
A: See this link https://en.wikipedia.org/wiki/Metric_tensor#Area, Although it's only for area, you can generalize it such that it works even in 4D (i.e curved spacetime). You might find volume form section useful as well.
If you want a better proof, check General relativity: an introduction for physicists from M. P. Hobson, G. P. Efstathiou, A. N. Lasenby.
Manifolds and coordinates => Lengths, areas and volumes.
Edit: I am afraid it's not possible to give all of its explanations here, but what it actually says is that for finding area, volume, 4D volume, etc you need to multiply proper length of line segments. 
A: This factor is just the Jacobian determinant which enters an integral if you switch to curvilinear coordinates from Cartesian coordinates which can be defined in a neighbourhood of any point. See also https://math.stackexchange.com/questions/923675/difference-between-the-jacobian-matrix-and-the-metric-tensor
