No-one is really sure but it appears to be related to a clock face.
The only thing that is virtually certain about this question is that it likely to have originated in France where tennis (or, more accurately, “real tennis”) was a popular pastime in the 12th Century.
It is believed that tennis courts would usually incorporate a clock and the face of this provided the basis for the scoring system.
A full rotation of the clock face was required to win a game – split across four points, creating a scoring system that therefore went 15, 30, 45 and 60.
It was decided that players needed to win a game by two clear points and therefore since the gap between 45 and 60 does not split in half well, 45 was reduced to 40 to effectively amend the scoring to 15, 30, 40, 50, 60 when players tied at 45 each.
Interestingly, the 40-40 score which we all know as “deuce” in the English language is likely borrowed from the French word “deux” meaning two (as in, two points required to win) but those who have ever seen the French Open on TV will know that the French language uses the term “egalité” to signify what we call deuce. Go figure.
Other theories exist about the scoring system but the one explained above seems the most credible.