My handlebars wobble when I am gripping the center of my handlebars at moderate-high speed. When holding the grips on the end of the bar it's fine but I like to sometimes give my hands a rest with a center grip. How can you prevent this condition?
Check the front wheel rim and tire are running true. Lift the front wheel off the ground and spin it. Looking at the rim and tire where they pass through the fork or rim brake makes it easier to see how much deviation from true there is.
If rim has more than a few mm of deviation, you can get a local bike shop to true it. If the tire is not on straight, deflate it, get it seated on the rim properly and re-inflate. Also check the tire for bulges or damage.
Check you have the wheel fixed in the fork correctly and the QR or thru-axle is done up sufficiently tightly.
Check the headset bearings. Hold the handlebars, apply front brake to rock the wheel and rock the bike forwards and backwards. If you feel any play between the fork and frame the headset bearing pre-load need to be adjusted. There are plenty of guides online that will show you how to do that.
BTW, you probably should not be gripping the bar in the center (right up against the stem) at high speed. You will have poor steering control and will not be able to get on the brakes in an emergency.
Another possible cause is speed wobble, a phenomenon where steering, the frame and your body mass together create a sudden strong oscillation. There isn't a way to prevent it except switching to a stiffer frame, but fortunately it is easy to recover by changing the grip on handlebars or just touching top tube with your leg.