The Odyssey was most likely written in the eighth or ninth century B.C. by Homer, but no one knows for sure.
The Odyssey tells a tale of a hero from long ago, as is evidenced from the opening line.
TELL ME, O MUSE, of that ingenious hero who traveled far and wide after he had sacked the famous town of Troy. (book 1, ch 6)
It is impossible to give an exact date for when The Odyssey was written. It is clearly written after the Trojan War in Ancient Greece. We are not even entirely sure who wrote it, even though it is widely attributed to Homer. We do not even know when Homer lived.
Still, the common theory dictates that Homer lived on the western coast of Asia Minor (in modern-day Turkey) in the city of Smyrna circa the eighth or ninth century B.C. (enotes, overview)
The Trojan war “was already several centuries old in Homer’s day” (enotes, overview). None of the original texts survived, but the “earliest papyrus fragments date back to the 3rd century BC” (Wikipedia). Some scholars believe The Odyssey is even older (salon.com).
In the end, it does not really matter what The Odyssey was written. It captures a long ago time in a beautiful and entertaining way, whoever wrote it.