Back before the Federation and Starfleet were formed, United Earth had the Military Assault Command Operations (MACO). MACO was primarily tasked with duties that were based on Earth and it was not until a unit's assignment to the NX-01 Enterprise under the command of Captain Jonathan Archer that they set foot in space for extraterrestrial duties in the Delphic Expanse. MACO truly was not ready for what battle on other worlds and with other species would require and that, combined with the fact that Starfleet tried to promote itself as a non-military organization while MACO was clearly military in nature, led to its disbanding upon founding of the United Federation of Planets and formation of Starfleet.
Though Starfleet likes to appear to be benevolent and scientific, those at Starfleet Command know and always have known that there needs to be a military aspect to the organization. With the disbanding of MACO, something else was needed.
Throughout the history of Starfleet, there have been covert operatives performing investigations for Starfleet Intelligence, the occasional Starfleet officer being assigned temporary duty along with others to form a covert direct action team, and the officially-nonexistent branch of ill-repute known as Section 31. None of these had been a good answer for what Starfleet truly needed: a highly-trained, rapid-response, direct action, covert team of operatives whose mission is to uphold the values of the Federation and perform to the best of their abilities when diplomacy and intelligence fail to get the job done. Starfleet Intelligence was only about gathering information. The direct action teams were run-of-the-mill Starfleet officers without the extra training or experience required to be the elite force that really needed to take on these missions to help ensure success. Section 31 had so little oversight that it was too unbridled to be trusted to act in the best interests of the Federation despite what its operatives might have believed. For this reason, the Advance Guard was formed.
Our first mission was one of subterfuge. The year was 2311. Tensions between the Federation and Romulan Star Empire were growing. Eventually, it led to what has been called the Tomed Incident.
According to the history books, thousands of Starfleet personnel perished when the Romulan flagship, the Tomed, crashed into a starbase at high warp. The containment field containing the quantum singularity within the Tomed's warp core failed and the explosion that resulted destroyed 13 Federation outposts and the USS Agamemnon.
The truth is that the Advance Guard, working with Starfleet Intelligence, had set up false lifesigns on all those outposts and the starship. So, the installations and ship were destroyed, yes, but there was no loss of life. In fact, the entire attack was staged by Starfleet Intelligence: there was no Romulan attack. This was a tactic used to cool the tensions between the Romulan Star Empire and the Federation. The result was that they backed off and sued for peace. This incident is what led to the Treaty of Algeron, the treaty that banned the Federation from developing its own cloaking technology and that redefined the Neutral Zone between our two regions of space.
Since our formation, we have executed precision strikes against our enemies, gathered intelligence, developed advanced technology, and been the major offensive arm of Starfleet when finesse and speed were essential. By the time that the rest of Starfleet hears about a coming threat, we have already known about it and addressed it in some fashion for at least a year. We soften any blows that Starfleet may endure but we prevent most threats before anyone within mainstream Starfleet knows that the threat ever existed.