I think it came from the Indian game, Chaturanga.
who invented the chess and when?

Precursors to chess originated in India during the Gupta Empire.[4] There, its early form in the 6th century was known as chaturaṅga, which translates as "four divisions (of the military)": infantry, cavalry, elephantry, and chariotry. These forms are represented by the pieces that would evolve into the modern pawn, knight, bishop, and rook, respectively.[5]

playing chess results in better brain function, improved memory and cognitive abilities, strategic thinking and attention improvement.

chess was found in india by some 6th century where the youngest prince of the gupta empire was killed in battle his brother represented the scene to their greaving mother the game was played in the ashtapada board ashta means 8 and pada means squares in the middle there is one and others are in the corners of the ashtapada board. the games name was chaturanga meaning 4 divisions.then it spread to persia where it got it's name chess in persian shah meaning king
and shahmat meaning the king is helpless
then it spread to many countreis like china,europe and many more but in europe is where chess got it's present form

I tend to accept the traditional accounts of the birth of chess, but GM Raymond Keene has an interesting theory. This article is worth reading:
https://www.thearticle.com/did-roman-emperors-play-chess

It was invented in India in 8th but no one knows how invented
Had to be earlier than that. It wasn’t a new game when I introduced it to Europe in the early ninth century.

Garry Chess invented chess. I believe it was around 1980 that the game was being beta tested, and it was released to the public in 1985. Garry Chess Came up with the idea in 1978, and sold it off to the company that is now known as Chess Inc. in 1987. It was expected to be renamed to Multi-Square Turn-Based Army-Combat, but right before he sold the company, Garry Chess asked if the game could keep its current name, and Chess Inc. said yes.
I should say nobody (alive) knows EXACTLY who invented it and when.
as for india. yes thats a popular theory. but the best website I perused said the birthplace was unclear and disputed.
from http://history.chess.free.fr/origins.htm
"The quest of Chess origin is an exciting riddle. This question is still unsolved today despite what can be said or read here or there.
These pages aim at gathering all elements at our disposal. Everyone will then make his own mind.
Chess sprang in History in Persia around 600 A.D., already opposing two armies of 16 pieces each. Searching earlier than that is diving in the game prehistory, in the myths and legends. Every civilization has its own. For the Indians, Chess was invented by a queen of Ceylan (Lanka) besieged by god Râma. For the Chineses, it was invented by the mythical Emperor Shennong or by his successor, Huangdi. For the Arabs and the Persians, it was a wise Indian, Gaw or Sassa (Sissa) with his wheat seeds... For medieaval Europeans, it was Xerxes, a Chaldean philosoph (Xerxes=Sassa?) or maybe it was Alexander the Great, or Ulysses, or the Egyptian queen Nefertiti or maybe Adam to forget Abel's death... Of course, this is not History. Well, so when, where, how Chess was born?
There is no doubt now that Chess is ... an Asiatic game. Three regions may claim to be its cradle: North of India, Central Asia from Iran to Turkestan and Eastern China. No one can object that there is a "genetic" link between all forms of Chess coming from these areas.
For most educated people, there is no question. The main stream theory is Chess was born in India in the 6th century at latest. That's all. Nevertheless, this vision is poorly informed and lies, mainly, on the intuitions of a chain of bright English historians and intellectuals, obviously impressed by the wealth and depth of the Indian civilization at the time where India was under the British rules: Hyde (1694), Jones (1790), Forbes (1860) et Murray (1913). Without denying how important was their contribution for the studies of India, it is clear that possible contribution of other cultures were not envisaged with the same intensity. To make it short, let's say that the main stream theory lacks of definitive proofs."
Hey, The name of original chess is chaturanga and not chatrang.
I think that chess was a way to make war strategies for Persians and Arabs but that's just me