Drawing electoral district borders is difficult to think of as an optimal outcome in the mechanism design of elections. It has all the ingredients that lead to manipulation by the incumbent majority, leading to suboptimal persistence of power. On the surface of it, it would much simpler and less strategic to just have everyone elect as many people as there are openings within a jurisdiction (say, a US state for federal elections), which has the advantage of giving smaller parties a fighting chance, and forget about districts and especially that ludicrous gerrymandering.
Yet, Emanuele Bracco think one can optimize the districting process. The key aspect here is that the parties platform is endogenous, that is, they are responsive to the electorate's wishes, as all the parties care about is getting elected. Parties tries to match the preferences of the median district- While this seems to be a rather romanticized view of elections in some countries, an interesting result is that if the electorate is risk averse, the majority party actually suffers from redistricting, while it would have benefited under exogenous platforms. So there is some hope that the US electoral system is not beyond repair. I still wish there would be a few viable small parties, though.