We consider a right circular cylinder, with radius $r$ and height $h$. We will put the center of its base at the origin, and have the $z$ axis coincident with the axis of the cylinder. We can, therefore, describe a point on the cylinder using cylindrical coordinates $\rho,\theta,z$. Let $P(\rho_p,\theta_p,z_p)$ and $Q(\rho_q,\theta_q,z_q)$ be two points on the cylinder, and let us suppose that $z_p\not=z_q$.
There are two arguments for why the geodesic is a helix. The first is a simple argument involving flattening out the cylinder, noting that the resulting geodesic is a straight line, and then curving the flattened surface back into the cylinder. The result is the helix.
A more rigorous argument involving the calculus of variations follows:
Now the usual differential of arc length in cylindrical coordinates simplifies down to
$$ds=\sqrt{\rho^2 (d\theta)^2+(dz)^2}.$$
The distance $s$ between points $P$ and $Q$ is therefore
$$s=\int_{z_p}^{z_q}\left[\rho^2\left(\frac{d\theta}{dz}\right)^{\!2}+1\right]^{1/2} \, dz.$$
We identify
$$f(\theta,\theta',z)=\left[\rho^2\left(\frac{d\theta}{dz}\right)^{\!2}+1\right]^{1/2},$$
and since the explicit dependence on $\theta$ is absent, we can use the "alternate" form of the Euler equation:
$$f-\theta' \, \frac{\partial f}{\partial \theta'}=a,$$
where $a$ is a constant. This results in
\begin{align*}
a&=\left[\rho^2\left(\frac{d\theta}{dz}\right)^{\!2}+1\right]^{1/2}-\theta' \frac{\partial}{\partial\theta'}\left[\rho^2\left(\frac{d\theta}{dz}\right)^{\!2}+1\right]^{1/2} \\
&=\left[\rho^2\left(\frac{d\theta}{dz}\right)^{\!2}+1\right]^{1/2}-\theta' \frac12 \left[\rho^2\left(\frac{d\theta}{dz}\right)^{\!2}+1\right]^{-1/2}
\left(2\rho^2\d{\theta}{z}\right) \\
&=\left[\rho^2\left(\frac{d\theta}{dz}\right)^{\!2}+1\right]^{1/2}-(\theta')^2 \rho^2 \left[\rho^2\left(\frac{d\theta}{dz}\right)^{\!2}+1\right]^{-1/2}
\quad\implies \\
1&=a\sqrt{\rho^2(\theta')^2+1} \implies \\
\frac{1}{a^2}&=\rho^2(\theta')^2+1 \implies \\
(\theta')^2&=\frac{1-a^2}{a^2\rho^2} \implies \\
\theta'&=\frac{\sqrt{1-a^2}}{a\rho} \implies \\
\theta&=\frac{z\sqrt{1-a^2}}{a\rho},
\end{align*}
which is the equation of a helix.