relation between the demand function and the marginal utility function
This is true for quasilinear utility function. Suppose
$$U = d + V(x),
$$
where $d$ is the numeraire. The budget constraint is given by $p_x x + d = I$. The utility is then
$$U = I - p_x x + V(x).$$
Maximizing this, we have the following FOC: $p_x = V'(x)$. That is, for a given $x$, my willingness to pay is $V'(x)$, the marginal utility.