The horizontal velocity controls how much progress the projectile can make per unit time. The higher the velocity the farther it can get in a fixed time.
The vertical velocity controls how much time it will take before the projectile hits the ground. The higher the velocity the more time before it lands.
The goal is to maximize total distance. So you want to maximize the product of horizontal velocity and time.
Clearly a purely vertical trajectory is suboptimal. You maximize time, but the resulting distance is zero.
Clearly a purely horizontal trajectory is suboptimal. You maximize horizontal velocity, but the resulting distance is, again, zero.
The horizontal velocity scales as the sine of the elevation above the horizontal
The vertical velocity scales as the cosine of the elevation above the horizontal.
You can apply the halfangle formula and derive that the maximum must be at 45 degrees because sin(theta)cos(theta)/2 = sin(2 theta) and sin(2 theta) is maximized when 2 theta = 90 degrees so theta = 45 degrees.
Or you can notice the symmetry and realize that if there is a single maximum then it must occur at 45 degrees.
Or you can look at the first derivitive of sin(theta)cos(theta). By the product rule, that's ( sin(theta) * d cos(theta) + cos(theta) * d sin(theta) ) / d theta
And that's cos^2(theta)  sin^2(theta). The maximum is obtained when this result is zero. So cos^2(theta) = sin^2(theta). In the first quadrant, that means that cos(theta) = sin(theta). By inspection that occurs at theta = 45 degrees.
