It is instructive to analyze the encounter from the inertial system at rest relative to the planet2; this inertial system is moving with the planet's velocity $U$ relative to the "resting" observer. This is possible because the physics don't change when we look at them from another inertial system.
From the planet's point of view the encounter is unspectacular: A small probe will approach, perform a U-turn and then leave with the same speed,1 which we call $v_{rel}$ (vor relative velocity, relative to the planet).
Now transform the probe's relative speeds to the ones a "resting" observer sees, simply by compensating for the planet's movement by subtracting its velocity vector. This means
- subtract the planet's speed from the approaching probe (because its approach seems faster watched from the planet than it "actually" is since the planet is "actually" moving towards it);
- and add the planet's speed to the leaving probe (its departure appears slower from the planet because the planet is following it).
Voilà, the result: The approaching probe's speed from an observer's point of view is $v_{rel}-U$ and the departing speed is $v_{rel}+U$, a difference of 2U.
This explanation is not a sleight of hand but perfectly valid physics. For a more intuitive approach, let's replace the gravity U-turn with an elastic collision, say with springs between the probe and the planet. (The physics are essentially the same because ideally no friction is involved.) The impact of the planet's motion then is two-fold: Not only do the springs get loaded more; the motion also adds more *oomph* to the back-bounce because it is pushing "in addition" to the springs.
This mechanism is what makes stacked balls bounce high, and as the linked page shows, can be understood with the same change of inertial systems.
1 We look at speeds "far away", ignoring the acceleration when entering and leaving the planet's gravity well which is a zero sum game.
2 The planet is on an elliptic orbit, so strictly spoken not the origin of an inertial system; but the error during the brief encounter is small. After all we usually consider physics classrooms inertial systems, even though they most certainly aren't ...
history
tag because the origin of the formula may be much older than spaceflight, it could probably be derived from simple kinematics. Can you add a link to the source where you've found this formula? It might help if you look for other sources as well. I think the distance of closest approach (altitude) can be calculated from the initial conditions; once you choose $u$, $v$ and $\theta$ I think the distance of closest approach is already predetermined. It would be nice to have a diagram that shows what $\theta$ represents in your formula. $\endgroup$