TL;DR
The rule has no economical meaning and no theoretical foundation.
3% of deficit per GDP is slightly higher than what could be expected in June 1981 for the forthcoming year in France. The figure looked convenient. That's how it was adopted.
The history of the deficit per GDP ratio is amazing.
It was created by two bureaucrats in France in June 1981, proclaimed by President Mitterrand in 1982, and included into the national political debate during the following decade. Later, French negotiation team for the Maastricht Treaty suggested in 1990 to include the 3% rule to answer Germany's demands for budgetary constraints.
It was "written in the marble" of the Treaty when it got accepted in 1992.
Back in the 1970's after it was hit by the First Oil Shock, France discovered public deficits. President Giscard D'Estaing put a threshold defined by an absolute number, at 30b Francs, and abided to it until 1980, although he asked his administration to twist the numbers to have them look brighter on election years.
1981 was a tough election year for him, and he let the spending go loose to try and keep more electors. However he was defeated by François Mitterrand. When the Socialist took office, the budget deficit for 1981 was reevaluated to 55 billion Francs - way off Giscard's self-set limit.
Mitterrand's program included vast public spending and the Second Oil Shock had hit: first previsions for the 1982 budget included a deficit of 100b Francs, a scary figure. Moreover, he had to face a lot of his Ministers (new to the office) asking him for more budget. One evening in June 1981, he informally asked bureaucrats, namely Luc Abeille, Roland de Villepin and Pierre Bilger, for a simple rule he could oppose to his Ministers to tame their greed.
In less than one hour, without building their figures on any economic or theoretical doxa, Abeille and Villepin made some back-of-the-envelope calculations to find a simple indicator that didn't risk being bypassed during the coming year, and invented both the deficit per GDP ratio and the 3% threshold.
From Abeille's testimony:
Pressés, en mal d'idée, mais conscients du garant de sérieux qu'apporte l'exhibition du PIB et de l'emprise que sur tout esprit un peu, mais pas trop, frotté d'économie exerce sa présence, nous fabriquons donc le ratio élémentaire déficit sur PIB, objet bien rond, jolie chimère (au sens premier du mot), conscients tout de même de faire, assez couverts par le statut que nous confèrent nos études, un peu joujou avec notre boîte à outil. Mais nous n'avons pas mieux. Ce sera ce ratio. Reste à le flanquer d'un taux. C'est affaire d'une seconde. Nous regardons quelle est la plus récente prévision de PIB projetée par l'INSEE pour 1982. Nous faisons entrer dans notre calculette le spectre des 100 milliards de déficit qui bouge sur notre bureau pour le budget en préparation. Le rapport des deux n'est pas loin de donner 3%.
C'est bien, 3% ; ça n'a pas d'autre fondement que celui des circonstances, mais c'est bien.
An approximate translation:
In a hurry, lacking ideas, but reckoning that a reference to the GDP ensures to be taken seriously, especially by those people who have studied a bit of economics but not too much, we build the elementary ratio deficit on GDP, a round object, a nice chimera (using the word etymologically), conscious that, protected by the respect paid to our background, we are just toying with items from our toolbox. But we have nothing better. It will be the ratio. Remains to attach a rate to it. The matter of one second. We look at the latest forecast for the GDP in 1982 by INSEE (French National Institute of Statistics). We put into our calculator the dreaded 100 billions of deficit that dances on our desk for the preparation of the budget. The quotient of the two values is not very far from 3%.
It is nice, 3%; it has no other foundation than the circumstances, but it's nice.
And thus the back-of-the envelope calculation got accepted. During the following year, several ministers (Fabius, Delors, Mauroy) sometimes mentioned the 3% threshold in interviews.
François Mitterrand in June 1982 will make the first official reference to the 3% ratio:
Bref, il nous faut compléter les conditions de la croissance telles qu'elles ont été engagées l'année dernière. Les moyens en sont la priorité à l'investissement et à l'innovation et, secundo, la maîtrise du déficit du budget de l'Etat. Ce déficit est d'environ 3 % et il ne faut pas qu'il dépasse ce pourcentage, appliqué au produit intérieur brut 'PIB'. Certes, on peut se prévaloir de ce que ce déficit est sans doute le plus faible à l'heure actuelle parmi les grands pays industrialisés. La question se pose, d'après les derniers chiffres, au regard de la Grande-Bretagne. Mais il est inférieur au déficit allemand, au déficit américain, au déficit japonais, au déficit italien.
(emphasis mine. The sentence in bold translates as "This deficit is about 3% and it should not go higher than this percentage, applied to the gross domestic product (GDP).")
Not only Mitterrand could set a limit that he was not going to cross in the next years, he avoided having to mention the scary nominal deficit "100b Francs" and he could even posture France as more virtuous than other Western economies.
Journalists took the bait; other politicians, including opponents, swallowed it as well: during the next decade, although it has no economical meaning, although it is not used elsewhere than in France, the 3% deficit-per-GDP rule will be a regular guest in the local political debate.
Fast forward to 1990. Another French bureaucrat, Jean-Claude Trichet, is leading a working group to prepare the Maastricht Treaty. German negotiators insist on including some rule for rigorous budgets. That's when the French ratio is proposed to Europe: although it is not backed by any economical science, it is easy to understand and happens to be pretty close to the average deficit-per-GDP ratio in the 12 countries of the EEC (which would become the EU).
The Treaty was adopted in 1992 and the 3%-rule became the standard for all countries adopting the Euro.