Their simplest function is to keep the back end at the back! They also provide the drive... without them the board would continue sideways towards the beach when you turn across the wave! This is called "spinning out".
Years ago boards had just the one single fin but this can lift out of the water in very tight turns and cause the board to once again "spin-out". For maximum performance surfing it is customary to also have fins out on the rails to allow maximum "crank" in the turns. The 3 fin "thruster" (all fins same size) has proven to be far and away the most popular set up for short to medium length boards.
Longboards tend to favour the original single fin design or "Performance Mal Set-up" which has a slightly reduced size centre fin with two smaller fins out on the rail known as "outriggers" or "outriders". This is also known as a 2+1 set up.
Everything else has been tried but the above set-ups are by far and away the most common. If fins interest you check out the Campbell Bros. website http://www.bonzer5.com
Campbell Bros unique Bonzer Design... ever seen one?