>>56413198Two ways mainly:
1. Set up on an enemy that intends to status you(if faster), switch out, or setup something else. If they are keeping up the pressure by attacking then that's what they are supposed to be doing to counter sub, it means you need to wait for a better chance.
2. Set up on an enemy that's going to do less than 1/4 of your HP no matter what. As the other anon points out this encourages Max HO EVs and at least one defensive stat, possibly with matching nature.
Substitute is usually paired with moves such as Protect and Toxic, and the best item will almost always be Leftovers