From Stein and Shakarchi Complex Analysis I'm having trouble understanding the process of Contour Integration, specifically the notion of "Singularities" of I observed that if $\zeta$ $\in$ $R$ , then the following occurs in 1.) $$ 1.) \, \, \, \, \, \, \, \, e^{-\pi\zeta^2}=\int_{-\infty}^{\infty}e^{-\pi x^2}e^{-2 \pi i x \zeta}dx$$
Initially I also made the observation if $\zeta$=0, then we have in 2.) $$2.) \, \, \, \, \, \, \, e^{-\pi(0)^2}=\int_{-\infty}^{\infty}e^{-\pi x^2}e^{-2\pi ix(0)}dx$$
Then obviously we arrive at the following Integral in 3.) $$ \, 3.) \, \, \, \, \, \, \, 1 = \int_{-\infty}^{\infty}e^{-\pi x^2}dx$$
Initially the authors had us suppose that $\zeta$ > 0 , and consider the function $f(z)= e^{-\pi z^2}$, which is holomorphic within the interior of the Toy Contour pictured in Figure 1.).
By Cauchy's Theorem it's I was able to make the observation that the following conclusion in 4.) $$4.) \, \, \, \int_{\gamma R}f(z)=0$$
Then next the function that was considered earlier was integrated over the real segment as follows in 5.) $$5.) \, \, \, \, \int_{-R}^{R}e^{-\pi z^2}$$
I'm having trouble justifying the initial step in 5.), from what I understand the function being integrated is initially called a "Singularity".
Initially in summary my question is: What are singularities and why are they important within Complex Analysis and also what kind of Singularity is our function that we're integrating ?
The main result of contour integration is the residue theorem. This concerns a a function $f$ which is holomorphic (i.e. complex differentiable) at all but finitely many points in its domain. It says that if you integrate such a function around a simple closed path $C$ with counterclockwise orientation, then the contour integral of $f$ around $C$ is $2 \pi i$ times the sum of all the residues of $f$ which are enclosed by the contour.* The residue of $f$ at a point $z_0$ is the coefficient of $(z-z_0)^{-1}$ in the Laurent expansion of $f$ about $z_0$; it will be nonzero only at a singularity of $f$ (which are just points where the function fails to be holomorphic).
The idea of the proof is simple enough, you can gain intuition by just computing the contour integral of $z^k$ around a loop for each integer $k$. It will vanish whenever $k \neq -1$ (because such functions have an unambiguous antiderivative, namely $\frac{z^{k+1}}{k+1}$), but it will not vanish when $k=-1$ (essentially because the complex logarithm is multivalued).
When we apply contour integration, we generally write down a family of closed curves in $\mathbb{C}$ which either exactly contain the region we want to integrate over or contain a region that approaches the region we want to integrate over. We then exactly compute these contour integrals, and then we take a limit that allows us to write our desired quantity in terms of the contour integral. Often the integration over the parts of the contour that we are not interested in will go to zero; other times we must actually compute them and subtract them from the integral over the whole contour to get what we want.
The most elementary example I can think of is $\int_{-\infty}^\infty \frac{1}{1+x^2} dx$. (This example is a bit boring, because we can do it using elementary calculus, but it illustrates the main concept.) To compute this, we use a semicircular contour in the upper half plane (or lower half plane, it doesn't matter in this case) centered at the origin and with radius $R$, and send $R \to \infty$ at the end of the calculation. For $R>1$, this contour will enclose the pole $i$ and no other poles. So our desired integral is $2 \pi i \operatorname{Res}(1/(1+z^2),i)$ minus the integral over the upper contour, which we then have to separately show goes to zero.
* Technically this can be generalized to non-simple closed paths, but I'll avoid this generalization.