Formed in 1622 by Louis XIII when he furnished a company of light cavalry Carabiniers with muskets. The Musketeers trained to fight both on foot as mounted infantry and on horseback, similar to dragoons. When the King travelled out side the Louvre (under Louis XIII) and later Versailles (under Louis XIV and after) and other royal residences they acted as a personal guard.
Soon after the first company was formed a second company was formed by Cardinal Richelieu. So as not to offend the King with a perceived sense of self-importance, Richelieu did not name them Garde du Corps like the King's personal guards but rather Musketeers after the Kings'junior guard cavalry. This was the start of a bitter rivalry between both corps of Musketeers. Upon the death of Richelieu his succesor Mazarin gained the second company, however he disbanded them in 1646. In 1657 the company was reformed with 150men. When Cardinal Mazarin died in 1661, King Louis XIV assumed them and added them to the other company. As the original company became the first company they were called the "mousquetaires gris" because this company rode grey horses, the former compnay of the cardinal became the "mousquetaires noirs" due to the colour of their horses being black. It was about this time that the companies doubled in size.
Of all the companies of the Kings army the musketeers were among the most prestigious. Many of the musketeers were nobility because the army reforms of Michel Tellier mandated that nobles would no longer be promoted to officer based soley on their rank, and had to serve for a period of time before they could be considered for promotion. Service in the Musketeers meant that they would be in the presence of the King, and their courage might recommend a commision from him.
On the eve of France's entrance in the American War, King Louis XVI again disbanded the Musketeers due to monitary shortfalls. Reformed on the eve of the French Revolution they were disbanded again. Upon the 1st restoration in 1814 they were formed but disbanded again in 1816.
In 1844, Dumas wrote the first of his novels which included some very real personages or composites of real characters, Charles de Batz-Castelmore, Comte d'Artagnan really existed, as did Aramis, Athos, and Porthos whose nom-de-guerres reflected their real name and station.
Dieu le Roy!
References:NecPluribusImpar, parJeanVial http://vial.jean.free.fr/new_npi/archives/archiv.htm
New York Public Library digital images, the The Vinkhuijzen collection of military uniforms, (France) http://digitalgallery.nypl.org/nypldigital/dgtitle_tree.cfm?title_id=614958&level=2&tword=