The Right Knee Flex during the Backswing
The right knee has an important role in the backswing. It restores all the power during the backswing.
You can shift your weight correctly if you keep your right knee flexed.
If your right knee straightens out, you will leave your weight on your front foot. If your right knee slides to the right too much, you will tend to have a reserve pivot.
Your right knee can move slightly to the right during the backswing but not too much.
If it slides to the right, your hips will slide to the right as well. If this happens, you will fail to turn your shoulders.
Your Spine Angle
I have said this many times and will say this again. Check your spine angle at address. It should be tilted to the right a little.
If it's vertical at address, you are going to have to slide to the right in order to move your weight to your back foot.
When you slide your hips, you will lose the flex in your right knee.
If you tilt your spine to the right at address, it makes it easier to turn and shift weight. So you don't have to worry about the right knee flex.
Also, when you have a weak grip, you right knee tends to straighten during the backswing. So check your grip as well. It might be the cause for the bad shots you are hitting.
Some teachers tell you to keep your right knee flexed. But when you follow his advice, you might hit a slice or weak shots to the right.
You might be straightening your right leg unconsciously in order to prevent the clubface from opening so much during the backswing because you had a weak grip.
In this case, your weak grip is the cause. So even if you try to keep the flex in your right knee, you won't gain distance or fix your slice.
So it's really important to find the root of the problem. Too much golfers try hard to fix the outcome itself and struggle for a long time. I know this because I did the same thing and struggled for many years.
The Drill for Right Knee Flex
Here is the drill to keep the flex in your right knee.
Putt a golf ball under the heel of your right foot. As you swing back, try to press the ball against the ground.
If you slide, you'll lose balance. So this would be a good drill. Focus on turning of your shoulders and hips.
You can actually hit some shots with your middle iron with a ball under your right heel.