First, call its initial velocity $v$ and height $h$.
Here is the equation modelling the trajectory of the projectile: $y = h + x \tan \theta - \frac{g}{2v^2} x^2 (1 + \tan^2 \theta)$. We want to find where the projectile hits the ground, so let $y = 0$. We can now use calculus to find the maximum by differentiating w.r.t $\theta$.
$$x \sec^2 \theta + \tan \theta\frac{dx}{d \theta} - \left(\frac{gx}{v^2} \frac{dx}{d \theta} (1 + \tan^2 \theta) + \frac{gx^2}{2v^2} (2 \tan \theta \sec^2 \theta)\right) = 0$$
So $$\frac{dx}{d \theta} = \frac{x \sec^2 \theta \left(\frac{gx}{v^2} \tan \theta - 1\right)}{\tan \theta - \frac{gx}{v^2} (1 + \tan^2 \theta)}$$
So we find a critical value in $\tan \theta = \frac{v^2}{gx}$, and can substitute it back in the original equation:
$0 = h + \frac{v^2}{g} - \frac{g}{2v^2} x^2 - \frac{v^2}{2g}$ so $x = \frac{v}{g} \sqrt{v^2 + 2gh}$.
To find the angle, substitute in above to get $\theta = \tan^{-1} \left(\frac{v}{\sqrt{v^2 + 2gh}}\right)$
Notes: If you don't trust that this is a maximum, finding the second derivative is left as an exercise to the OP :)
Best Answer
Have you tried to search the net for 'projectile initial height'?
A few first hits contain e.g.
which all seem to give answer to your problem.
EDIT
Also Maximum range of a projectile (launched from an elevation) here, at Math SE, seems to be the same problem as yours.