The way the celebrity status and mass amount of courses globally have grown, one would think that the game of golf was thousands of years old or as old as entertainment itself. While there have been similar versions of the game, apocryphally recorded which involved a leather ball and club, the winner being the participant that got the ball into a hold several hundred meters away in the fewest amount of swings. This game was first played in Loenen aan de Vecht by the Dutch in 1297. Thus it is generally accepted that modern game of golf developed in The Netherlands during the Middle Ages.
Other versions of the game were played in continental Europe. There has always been a lot of speculation and debate on the actual beginnings of the game, however, given the advancement of travel between European nations around the same periods, it certainly could be argued that the game may have evolved from multiple versions played in different nations at different times.
It is widely accepted however that the mainstream playing of the game originated in Scotland around the 19th century, it spread into the rest of Great Britain then into the British Empire and the United States.
A fun fact: A rumor has circulated in recent years that Golf is an acronym for Men only Women forbidden. This is a 21st-century rumor and while completely false. In fact, the origins of the word golf have as much speculation as the origins of the game itself.
The game had a very colourful first 500 years quick facts of which can be found via this link below, including being banned from being played several times by governments.