I'm still wondering why would football teams do a fair catch if they could run to gain some yards. And, why would the NFL make that sort of rule? Is it because of some sort of safety reason?
Typically, a fair catch is called when no yards will be gained if a return was attempted, e.g., when a player of the kicking team is going to crush the returner the moment the ball touches him. It allows the receiving team to safely retain possession while saving the defenseless returner from taking a crushing hit from a player moving at full steam. So yes, there is a safety reason, as well as a practical one, as holding onto the ball after taking a hard hit isn't a guarantee. If the returner fumbles the catch, the kicking team could potentially keep possession by recovering the ball.
As the receiving team, you forfeit your ability to better your field position by running after the catch when you call a fair catch, but you ensure that you at least retain possession. If the fair catch rule didn't existing, receiving teams would often find themselves with very poor field position, as they'd likely elect to let the ball bounce to save their returner and ensure possession. This provides the kicking team the advantage of allowing the ball to continue to bounce and roll backwards until they touch it and the receiving team is given possession at that spot.
Yes it is for safety. The main reason is so your returner doesn't get his ass rocked. For instance you could have a punter specialize in punting the ball high 30 yards. Coverage would be on top of returner. If he catches it without a fair catch he will be maimed. If he doesn't catch it on a turf field the punt could bounce for 60 years. Turf does come into the equation on this because not only does the ball bounce further and generally in the direction it traveled but the gunners also generally make it down the field faster. The modern game has definitely made the punt a lot more dangerous.
I might as well add something the other answers missed out on. Once in a long while, a team receiving a fair-catch can elect to do a free-kick from the point where the fair catch was called and caught. There have been very few occasions of these and even then, they are usually done in the last seconds of either half.
For the receiving team, a more important priority than "advancing" the ball, is retaining possession. A team is much better off with the ball at yard x than advancing it to yard x+1 or x+2 and turning it back over to the kicking team.
In order to prevent a turnover, a receiver must "secure" the ball (1-2 seconds), before running with it. A receiver calls for a "fair catch" if the defenders are so near that the receiver believes that he will be tackled in that 1-2 second interval during which he will secure the ball. That is, he will not be able to start running before being tackled, and fears the possibility of a fumble.
Earlier in the history of the game, the fair catch was undertaken with the receiver having one knee on the ground (basically the definition of being tackled). With the receiver having thus "tackled" himself, there was no need for the kicking team to tackle him, and they lost the right to do this, or otherwise interfere with the catch.