(covers information from several alternate timelines)
The Captain's Oath was an oath for Starfleet captains which they took when assuming the command of a starship that outlined the mission and objectives of the given ship in the United Federation of Planets and the core values Starfleet stood for. (Star Trek Into Darkness)
Some of the words in the Captain's Oath were based on the historic speech given by Zefram Cochrane at the dedication ceremony of the Warp Five Complex in 2119. A recording of this speech was broadcasted, when Enterprise NX-01 was launched in 2151. In his speech Cochrane said: "Imagine it. Thousands of inhabited planets at our fingertips. And we'll be able to explore those strange new worlds and seek out new life and new civilizations. This engine will let us go boldly where no man has gone before." (ENT: "Broken Bow")
In 2258 in the alternate reality, Captain James T. Kirk was asked to recite the Captain's Oath by Christopher Pike before assuming command of the USS Enterprise. At the time, he didn't appreciate the meaning of the words in the oath. Nearly a year after Khan's attacks, at the ship's rechristening ceremony, Kirk recited the oath again. At that time, he felt that the oath was a call for the Federation to remember who they had once been, and who they must become again.
For the mission on which the Enterprise was about to embark, the Captain's Oath was "Space: the final frontier. These are the voyages of the starship Enterprise. Her five-year mission: to explore strange new worlds. To seek out new life and new civilizations. To boldly go where no one has gone before." (Star Trek Into Darkness)
When the crew took up the brand new USS Enterprise-A the entire crew took the Captain's Oath: "Space: the final frontier. These are the voyages of the starship Enterprise. Its continuing mission: to explore strange new worlds. To seek out new life and new civilizations. To boldly go where no one has gone before." (Star Trek Beyond)
The final words of the oath have been inscribed to the dedication plaques of most starships named Enterprise that have served, among other duties, as ships of exploration for the United Earth and the Federation. (Star Trek: Enterprise; Star Trek: The Next Generation; Star Trek films, set artwork)
The oath Starfleet captains made also implicitly meant they were required to sacrifice their own life and the lives of their crew rather than violate the Prime Directive. (TOS: "Bread and Circuses", "The Omega Glory")
In 2376, Captain Kathryn Janeway reminded Captain Rudolph Ransom of the oath he had taken "to seek out life, not destroy it," when it was discovered he was responsible for murdering several nucleogenic lifeforms. (VOY: "Equinox")
The Captain's Oath in Star Trek Into Darkness was a revised version of the well known monologue by William Shatner's James T. Kirk from the title sequence of Star Trek: The Original Series. However, Kirk's recital of the oath in the film marks the first time that it appears as part of dialogue and not as a voice-over speech, only spoken to the audience.
In Star Trek After Darkness, Part 1, Kirk was interrupted as he was reciting the oath again for his captain's log. Leonard McCoy called the oath a beautiful ode to the captain's job. Kirk thought it was important and good for the soul to reflect on why they were out there in deep space.