The election of Phil Gramm, co-sponsor of the Reagan budget who switched parties and won a seat as a Republican congressman last week, is that rarest of political events: the one that benefits everyone.

Gramm gets back the House seat he wanted. The people in his Texas district keep the congressman they like to have speaking for them. The Democrats get rid of a member they regarded as a detriment and embarrassment to the party. And Ronald Reagan gets a new Republican member who is his kind of guy.

It is so rare that one person can bring so much satisfaction that one must ask: who is Phil Gramm?

He is a 40-year-old former economics professor, with an intent, owlish look, a solemn and sometimes self-important manner, a serious, almost humorless demeanor. The Texas Observer, which dislikes him, called him "a conservative who fights for what he believes." He believes in less government. But he got to this belief by a funny route.

He was born in Fort Benning, Ga., where his father was living on a veterans' disability pension. He went to the University of Georgia, where his tuition and expenses were paid by the War Orphans Act, sponsored in the House by the man he was to succeed in 1978, Rep. Olin (Tiger) Teague.

He was a physics major as an undergraduate and planned to take a graduate degree in that field. But when he talked to the people at the National Science Foundation in his junior year, he found that "physicists were starting off as post-docs (with PhDs, that is) at $5,100 a year, and then there'd be an instructorship for as many as five years and then a long, stairstep process to becoming a full professor. Just by accident, that year, 1963, economists were No. 1 in pay. It sounds very mercenary, but I took an economics course and liked it so I decided that since I wasn't going to save the world, I'd become an economist."

His graduate work was paid for by a National Defense Education Act fellowship.

The magic of the marketplace guided Gramm to the right profession, for he was a full professor of economics at Texas A&M at age 30. Having succeeded at that early age, he said, "I had three options. One was to try to move to a better school. Another was to become involved in academic politics and move up through administration. And the other one was to branch out and get into consulting, public policy and money-making. I decided on the latter."

Gramm and Associates, founded in 1971, was a profitable vehicle for him to become a writer, lecturer and consultant as "an advocate of fiscal responsibility and free enterprise."

From there it was but a short step to politics. "I didn't want anybody to think that I undervalued my abilities, so I decided (at age 34) to run for the U.S. Senate," challenging Sen. Lloyd Bentsen in the 1976 Democratic primary. Bentsen whipped him, but two years later Gramm was elected to the first of three terms in the House.

When I had the long interview with him in 1979 from which the above quotations are drawn, Gramm was still a Democrat. But he made the comment that one reason he lost to Bentsen in 1976 was that the Reagan- Ford Republican primary the same day "drew a large number of people who were my natural constituents."

In 1981, he found his fated partner in another upwardly mobile young man, David Stockman. While attending caucuses of House Budget Committee Democrats, Gramm privately agreed to co-sponsor the Reagan budget and to keep Stockman apprised of the Democrats' tactics. Stockman told William Greider during one of their celebrated interviews, "That's how I know what's in Jones's budget," referring to House Budget Committee Chairman James Jones.

The Democrats, justifiably sore at Gramm's guerrilla tactics, knocked him off the Budget Committee this year, at which point he resigned his seat and won re-election as a Republican. There is talk in Texas that he will run for the Senate, under his new label, at the earliest opportunity.

As I say, it is good to bring you this kind of heart-warming story. The Democrats will not really miss Phil Gramm, and Ronald Reagan will love having him in his party.

Gramm even has the kind of special slant on history that Reagan enjoys. During that 1979 interview, he told me that "our whole perception of the Industrial Revolution is one that's been colored by poets and novelists. . . . The plain facts were that . . . the people who came into the cities to work in sweatshops were entering the highest pay, best working conditions that they'd ever had in their lives."

In his new party, there's just no telling how far a talent like Phil Gramm can go.