Consider a random variable $X$ with density function $f(x)$, moment generating function $M(t):= \int e^{tx}f(x) dx$ (existing in an interval containing $0$), cumulant generating function $K(t):=\log M(t)$ and characteristic function $\rho(t):= M(it)$. Then I read the following equations.
\begin{align} f(x) &= \frac{1}{2\pi}\int_{-\infty}^\infty M(it)e^{-itx} dt \cdots\cdots\cdots\cdots\cdots(1)\\ &= \frac{n}{2\pi i}\int_{-i\infty}^{i\infty} M(nT)e^{-nTx} dT \cdots\cdots\cdots\cdot(2)\\ &= \frac{n}{2\pi i}\int_{\tau-i\infty}^{\tau+i\infty} M(nT)e^{-nTx} dT \cdots\cdots\cdots(3), \end{align}
where $\tau$ is any real number in the interval where $M(t)$ exists. I understand that $(1)$ is the inverse Fourier transform; $(2)$ is change of variable by setting $it=nT$. However, I do not know why we want to do $(2)$ in the first place. Moreover, I do not know how to get $(3)$ and why we want to do that. I have not done complex analysis. Could anyone explain these in a more intuitive way, if possible, please? Thank you!
The moment generating function is the Laplace transform of the probability density function. So, $f_X(x) \stackrel{\mathcal{L}}{\leftrightarrow} M_X(t)= E[e^{t X}]$ where $t$ is complex. The characteristic function is the Fourier transform of $f_X(x)$: $\phi_X(\omega) = E[e^{i \omega X}] = M_X(i \omega)$.
The inverse Laplace transform is given by the Bromwich integral, which says you can integrate the Laplace transform weighted by an exponential along any line in the complex plane with constant real part in order to recover the original function. Unfortunately, you need to know some complex analysis to get this (for (3)).
So, in (1), you take the inverse Laplace transform by integrating along the imaginary axis. Equivalently, when you plug in $t = i \omega$, the Moment generating function becomes the characteristic function (which is the Fourier transform of the density), and thus you take an inverse Fourier transform.