Why is 45° above horizontal the ideal angle to throw something the greatest distance if gravity is acting on the vertical direction but not the horizontal?
The 45° angle is ideal because it gives the ball a reasonable upward component of velocity and also a reasonable downfield component of velocity. The upward component is important because it determines how long the ball will stay off the ground. The downfield component is important because it determines how quickly the ball will travel downfield. If you use too much of the ball’s velocity to send it upward, it will stay off the ground a long time but will travel downfield too slowly to take advantage of that time. If you use too much of the ball’s velocity to send it downfield, it will cover the horizontal distances quickly but will stay of the ground for too short a time to travel very far. Thus an equal balance between the two (achieved at 45°) leads to the best distance. Note that this discussion is only true in the absence of air resistance.