As a historical novel, The Three Musketeers organizes its story around some of the major characters and events of 17th century French history. Cardinal Richelieu, Anne of Austria, and other important characters really lived and acted at least roughly the way they do in the novel. In fact, the historical basis of Dumas’s story extends all the way to his initial idea for the novel--even to the Musketeers and d'Artagnan themselves.
The Three Musketeers is inspired by a 17th century work entitled Memoires de d'Artagnan by Gatien de Cortilz de Sandras, which Dumas and Maquet stumbled across in their research. This work essentially became an outline for part I of The Three Musketeers. At the time, Dumas did not believe that the Cortilz novel was historical, but thought he was simply plagiarizing and developing a previous writer's work. But Dumas claimed in his original introduction to The Three Musketeers that he thought the work was historical, not wanting to seem plagiaristic himself. Ironically, the Memoires are, in fact, historically based.
D'Artagnan, the hero of The Three Musketeers, was really Charles de Batz-Castelmore, and hailed from Gascony, just as Dumas writes. He took the name of Sieur of Artagnan from a property his mother's family owned. He left Gascony not in 1625, as in the novel, but in 1640. He had a distinguished career not under Louis XIII and Richelieu, but their successors Mazarin and Louis XIV, and he rose through the ranks to great distinction until he died in service in 1673 at the Siege of Maestricht.
Athos, Porthos, and Aramis are also based on real Musketeers. Porthos was Isaac de Portau, a member of the Captain des Essarts's company of the King's Guards until 1643, and then a Musketeer with d'Artagnan (Charles Castelmore, that is). Aramis was Henry d'Aramitz, related to Monsieur de Treville, and Musketeer from 1640 on--we know little of him beyond that. Athos was Armand de Sillegue, Seigner d'Athos et d'Autevielle, also related to Treville. He was a King's Musketeer who died in Paris in 1643, but little is known beyond that--there is some indication on his death certificate that he died as a result of a duel.
The major historical figures in the novel are all more or less accurate, in terms of the basic facts presented. Louis XIII, Anne of Austria, Cardinal Richelieu, and Monsieur de Treville are all presented without grave historical inaccuracies. And there were, indeed, King's Musketeers under Louis XIII--they existed as a sort of training ground for the elite of the French army, and served as the King's personal escort in peacetime. Treville and the Cardinal were great adversaries, as Dumas portrays them--in fact, Treville was involved in a 1642 plot to assassinate the Cardinal, and Louis XIII was forced to banish his friend. And Richelieu did have his own, similarly elite, company of Guards, which did have a great rivalry with the Musketeers, as Dumas describes.
In general, then, we see that Dumas’s novel is at least based in history, although he takes great departures. The one great exception to this is Lady de Winter. Courtilz's "Milady" is an entirely private individual, one of the Queen's exiled ladies-in-waiting, with whom his d'Artagnan does indeed have an unscrupulous affair. But she has nothing to do with the Cardinal; certain faux-memoirs that Dumas used provided the detail of a lady "Clarick" who is associated with the theft of the diamond brooch from Buckingham that Dumas relates. Dumas fuses these elements, then, and creates an entirely fictitious character with his Milady. It is interesting that this fictitious character is allowed to so totally dominate part II of the novel, and this certainly says something about Dumas’s loyalty to historicity. Milady became a fascinating character, and Dumas was far more concerned with creating interesting fiction, and tying that into history, than in remaining blindly loyal to history.