Wikis say that the Tesseract came to Earth accidentally. How exactly, did it come to Earth?
The opening sequence of Captain America: The First Avenger, combined with the historical information at the start of Thor provides the answer. ~1000 years ago, Asgardians fought the Frost Giants on Earth as part of a cross-realm war. During a later war (or perhaps later battles in that same war), roughly 600 years ago the Tesseract was lost on Earth.
It was found by humans and hidden away in Norway. At the start of Captain America, the Red Skull finds the Tesseract and makes use of it to power HYDRA's weapons. In the end, it's dropped into the Atlantic ocean, and recovered by Tony Stark's father, Howard Stark. SHIELD held on to it in modern times, unable to unlock its secrets. Then it was discovered by Loki (Thors Brother) who wanted its power and the Avengers had to stop him. And when they were done it was brought back to Asgard.
In the beginning of Captain America: The First Avenger (2011), they show what seems to be a small house, or tomb if you will. When the leader of HYDRA starts speaking, he talks about the "treasure room of Odin" Odin's prize in that room was the Tessaract, and Odin lost it while fighting his battle with the Frost Giants on Earth. It was found and encased with a leader of Europe when he died. When people found the tomb they protected it when the found out what it (the Tessaract) was from legend.