Maximizing the number of districts that lean Republican causes the margins in those districts to shrink. it trades a few very safe districts for a larger number of moderately safe ones. That tradeoff is where the risk comes in. Gerrymandering doesnt simply make every district closeit actually trades a few very safe districts for a larger number of somewhat safe ones. That trade is what creates both the advantage and the risk.
Imagine a state with more voters from one party than the othersay 60 blue voters and 40 red voters, divided into five districts. If the districts are drawn fairly, the blue party might win three districts and the red party might win two, with each district having a comfortable margin. In that situation, most races are not especially close, so small changes in voter preferences dont change the outcome very much.
Now consider what happens if the lines are drawn to favor the red party. The blue voters might be packed into one district where they win overwhelmingly, while the remaining voters are spread across the other four districts so that red wins each of them. This produces a better outcome for redfour seats instead of threebut the margins in those four districts are no longer as large as before. Instead of winning comfortably, red is now winning several districts by more modest margins.
Thats where the risk comes in. Because the voters have been spread more thinly, a small shift in opinionjust a few voters in each districtcan flip multiple seats at once. In the fair map, those same small shifts might not be enough to change any outcomes, because the margins are larger. In the gerrymandered map, however, the advantage depends on maintaining several narrower leads, and those leads are easier to lose.
A simple way to put it is that gerrymandering turns a few very safe wins into a larger number of less secure ones. It can increase the number of seats a party wins, but it also makes those wins more vulnerable. Thats why a relatively small statewide swing can sometimes cause a dramatic reversal when districts have been drawn this way.