Every ten years, after the U.S. Census, states must redraw the boundaries of their legislative districts to reflect changes in population. This process is called "redistricting."
The main purpose of redistricting is to ensure that each district has approximately the same number of people, fulfilling the principle of "one person, one vote."
Gerrymandering happens when these district lines are drawn specifically to give one political party or group an unfair advantage in elections. By "packing" opposing voters into one district or "cracking" them across many districts, politicians can essentially choose their voters, rather than voters choosing their politicians.
In most states, the state legislature draws the maps. However, several states have moved to "independent redistricting commissions" to try and remove the political bias from the process.
Gerrymandered districts can lead to less competitive elections, more extreme political polarization, and a government that doesn't accurately reflect the will of the majority.