Propeller efficiency with pitch, taken from Aerodynamics for Naval Aviators, H.H.Hurt, 1965
Fixed pitch props need to be designed for a specific flight speed, which would invariably be a compromise between takeoff and cruise performance. By varying the propeller pitch, we can run the propeller blades at different angles of attack, and we slow the blade tips down to keep their relative speed (sum of freestream and tangential speeds) constant. Thus, we can run the propeller at a similar efficiency through all flight speeds.
Running the blades at certain angles of attack is not as simple as it sounds, with different tangential speeds along the radius of the propeller, the freestream and tangential speeds will yield different flow angles (highest at the hub, least at the tip). To achieve the same angle of attack everywhere along the blade, we'll then need to twist the blade, but as we cannot change the twist in flight, we can optimize only for one flight condition, and be content with a compromise.
Propeller blade twist. Prop's feathered in this picture, prop turns counterclockwise from the pilot's perspective (this blade moves down).
Another aspect is related to the performance of the engine. Reciprocating (piston) engines only recently had electronic fuel injection systems, thus most aero engines are reliant on having a throttle that restricts airflow to the engine to adjust power. To run the engine at part-power with a throttle is quite inefficient, as the engine actively spends power to suck air through the throttle (This is why newer auto engines have variable valve timing and cylinder shut-off and whatnot, to adjust engine power without choking it). By running the engine at an RPM lower than where it produces maximum power, we can run the engine at a higher throttle setting (ideally full throttle) with the same power.
Porsche 930 dyno graph.
Increasing blade pitch reduces RPM and moves the power (red graph) to the left of the graph, meaning less power at full throttle.
Porsche 930's engine was used as an aero engine by Mooney, with a 0.442:1 reduction gear.