It doesn’t prevent being rear ended all the time but the bigger the gap you have the more time you have for the dipstick behind you to notice your brake lights.
Even if that is to no avail, the longer the gap space is, the more deceleration space you have so that you may get pushed into the vehicle in front of you at a lower rate of speed.
I’ve done a whole lot of interstate driving over many years starting when they first opened in 1956. I always stay way behind traffic ahead of me usually parked about 5 over the limit. However, invariably some jagoff in a semi appears in my rearview mirror so close I can read the logo on the grill. Then it takes them 10 minutes to pass me and as soon as they get along side me I slow down and let the prick get ahead of me as fast as possible. I hate semis alongside me or tailgating.