Most of our currency was originally produced using valuable metals such as gold or silver. The purpose of these ridges, called ‘reeds’, is to prevent people from trying to harvest some of these precious metals by filing off a coin’s edges!
Different coins actually have different numbers of reeds. Of course, pennies and nickels don't have any at all. The coin with the most reeds is the 1-oz American Eagle Silver Coin, which has 201. There's a chart at the U.S. Mint's website that shows how many reeds each coin has.