My goal is to always be driving in "The Bubble" by maintaining space all around the vehicle. The faster you are going, the bigger the bubble needs to be. The general rule of thumb for following distance is one car length of cushion for each 10 mph of speed (on dry paved roads. Longer for gravel, wet, or icy roads) When possible, I try to at least double that.
But you also need to try to be aware of and control the bubble behind and to the sides of you. Obviously, you can't control the driver behind you directly, but if someone is following you at an unsafe distance, you can pull over and let them past you. You may have to do this more than once to get a driver behind you who gives you enough space. If there is no way to safely let the tailgater past you, you can try tapping your brakes a couple of times. Seeing those taillights come on usually gets you a safer buffer. It will also toggle off their cruise control if tthat was the problem.
You also need to monitor the adjacent lanes. This means learning to use your mirrors and making it a habit Don't drive alongside another driver for more than a few seconds. And especially don't sit in their blind spots at all. If traffic is heavy, it's better for you to be cruising a bit ahead of them than bit behind. Always assume that people entering traffic from a side road or driveway won't see you, and be prepared if the pull into your lane right in front of you.
Lots of stupid things can happen, but if you keep a big enough bubble around you, you'll be much safer. And everyone else will too.