The Eye of Agamotto was presumably built by the mystical being called Agamotto.
At some point it came into the possession of Doctor Strange and he wore it around his neck.
When Peter Parker was placed under the mental control of Baron Mordo he attacked the Sanctum Sanctorum as Spider-Man. Doctor Strange then used the power of the Eye of Agamotto to learn that Spider-Man had been placed under a spell by Baron Mordo. As Doctor Strange did this a third eye appeared on his forehead. Doctor Strange then used the Eye of Agamotto to remove the spell that Mordo placed on Spider-Man.
Later when Doctor Strange fought both Baron Mordo and Dormammu, Doctor Strange fired a beam from the Eye of Agamotto which hit them.
After Mordo was defeated Doctor Strange used the Eye of Agamotto to show Mary Jane Watson deep burried memories about her father and how he was abusive. This was enough to break Mordo's mental control over Mary Jane.
The Eye of Agamotto could be used to detect spells that were placed on people and remove them.
Doctor Strange could also fire a magical beam from the Eye of Agamotto.
The Eye of Agamotto could also allow it's user to see into people's minds.
In the comics
The third of the Vishantis, Agamotto, created three eyes, one of Power, one of Truth and one of Prescience. Doctor Strange's Eye of Agamotto is most commonly associated with the term.
The Eye of Agamotto's origin is currently unknown, but there are theories of how it came into existence. Some believe that it was discovered by Agamotto among the skies and stars, where it had drifted for ages. Others claim that it was created by Agamotto himself, which makes sense when the Eye's powers are compared to those of "the All-Seeing."
The eye itself resides within the amulet and is released from time to time as opposed to where a third eye appeared on Doctor Strange's forehead as it did on Spider-Man: The Animated Series.
It was placed in the care of Eternity until a worthy mage could successfully reach him. Doctor Strange did so and was given the Eye of Agamotto to battle Dormammu.
In the 2016 movie, Doctor Strange, the Eye of Agamotto is a container for the Time Stone which is one of the six Infinity Stones. The head of Marvel Studios, Kevin Feige, said in an interview "In this film, the Eye is a very important relic that can be quite dangerous if used in the wrong hands, because it has the ability to do any number of things, the most dangerous of which is, it can sort of manipulate probabilities. Which is also another way of saying, 'screw around with time' - which is part of our story."