45 degrees is, in fact, the angle for maximum range for a projectile with no air resistance. In the absence of air resistance, the only force acting is gravity, which causes a constant acceleration of g downwards. this determines the amount of time the particle spends in the air, via the formula for the position of a particle with constant acceleration:
$y(t) = y(0) + v_y t + \frac{1}{2}a_y t^2$
Putting in the relevant parameters (start and end positions both 0, acceleration -g (negative because it's downward)) this becomes:
$0 = v_y t - \frac{1}{2}g t^2$
which we solve to get:
$t = \frac{2v_y}{g}$
This time then goes into the equation for the horizontal position:
$x(t) = x(0) + v_x t + \frac{1}{2}a_x t^2$
As there's no horizontal force acting, this reduces to just
$x(t) = v_x t = \frac{2v_x v_y}{g}$
To get this in terms of the angle, we use the fact from trigonometry that for a velocity $v$ at an angle $\theta$ from the horizontal, the vertical velocity is $v \sin \theta$ and the horizontal velocity is $v \cos \theta$, giving us:
$x = \frac{2v \cos \theta v\sin \theta}{g} =\frac{v^2}{g}\sin 2\theta$
This has its maximum value for $\theta = \frac{\pi}{4}$, namely, 45 degrees from the horizontal.