Why can you deform the contour in the integral expression for the Klein-Gordon propagator to get the Euclidean propagator?

This is perhaps a bit unclear in the way Nair has written it, but it is essential that you make both the replacements $k_0=ik_4$ and $x^0=ix^4$ simultaneously. This keeps the convergence properties of the original integral intact.

Note that there is an additional sign in Nair's convention because he is changing from time-like quantities to a space-like quantities, which then get a different sign in the vector multiplication $k\cdot x$. Instead you could have done $k_0\to ik_0$ and $x^0\to -ix^0$, leaving them as time-like quantities. If you do it this way it's clear that you are just assigning $k_0$ and $x^0$ equal but opposite phases. Rather than a full $\pi/2$, you could have used any phase $k_0\to e^{i\theta}k_0$ and $x^0\to e^{-i\theta}x^0$ and it's clear that the product $k_0 x^0$ is unchanged.

I don't know if Nair covers this, but this addition of an imaginary part to the time coordinate has physical significance in perturbation theory. It introduces non-unitary evolution because the evolution operator $e^{-i\hat H x^0}$ is no longer unitary if $x^0$ has an imaginary part. This non-unitary evolution lets you automatically project out the interacting vacuum from the free vacuum, thus letting you build up perturbative approximations to quantities in the interacting theory using the ingredients of the free theory. I won't try to write the details in this answer, but these things are covered in Peskin & Schroder Ch.4, specifically pages 86-87 and 95.