Backgammon is descended from much older board games from Africa and West Asia like Senet and Tabula and Nard. It’s probably most closely related to the Royal Game of Ur, played in Sumer and in Shahr-i Sokhta (in modern Iran) about 3000 BC.
People in Iran seem to have been playing backgammon in more or less its modern form by the time of the Sassanid Empire, about 500 AD. About the same time, the Roman Emperor Zeno played a very similar game in Constantinople. By the Middle Ages (about 1050 AD), people were playing backgammon in Europe as well as in West Asia and Central Asia.
From Afghanistan to England, people used backgammon as a gambling game, betting money on rolls of the dice. To Europeans, this gambling seemed like a bad idea. King Louis IX banned backgammon in France for a while, and in the 1500s backgammon was banned in England too. In the Middle Ages, many Europeans thought playing this new foreign game of backgammon was a waste of time and would lead you to a bad life, just the way some people think of video games today.