When a golf ball flies through the air it forms a wake behind it, a vacuum, which holds it back. See the picture in a wind tunnel.

When a golf ball with dimples spins as it flies the 300-500 dimples cause the air to close up on the ball so there is no vacuum behind it and no turbulence to slow it down.
The dimples draw the air closer to the ball and make the wake smaller. The air sticks to the ball pushing it higher and forward so it goes further. This reduces drag and generates lift so the ball flies further and more stably.
Balls can be one piece to five pieces. The one piece is durable and has low spin and is mostly used in driving ranges made of surlyn. Urethene covered balls create more feel and control of spin. If you started golf as long ago as I did you will remember balata balls – long ago I used to play Titleist 364 balata. They had the softest feel on the clubface and were the best for the short game, but these are no longer legal.
The core is usually synthetic rubber . This drives the ball speed, compression and rebound. An intermediate casing covers the rubber in three or four pieces. They help find tune launch and spin. The outer cover is either surlyn for distance and toughness or urethane for greenside spin and control.
The two piece ball is made for maximum distance. Three piece and multi layer (4 to 5 pieces) have a smaller core and they are designed to have a lower spin for distance but greater spin and feel around the greens.

