The Senate yesterday passed a five-year. $51.5 billion federal aid to education bill after refusing to kill a "back to basics" program supported by the Carter administration.

The bill, approved 83 to 7, will continue all existing federal programs for elementary and secondary schools at a cost of more than $10 billion a year, and it adds new initiatives in competency testing and teaching the three Rs.

The House passed a slightly cheaper version of the same bill last month.

The bill, which goes to a House-Senate conference committee for reconciliation, survived repeated charges that it was a "budget boster" full of pet projects for the education lobby and its friends in Congress.

The most sustained effort yesterday came form Sen. Robert Morgan (D-N.C.) who attempted to eliminate a new program that would provide about $754 million over the next five years to beef up the teaching of basic skills - reading, writing and arithmetic.

Morgan argued that the measure would lead to further federal control over local schools and shouldn't be started when "we are trying to get spending under control." The amendment was defeated 60 to 30.

Sen. Claiborne Pell (D-R.I.), the bill's floor manager, said test scores of the ability of students to read and write are "declining and we had to do something about it."

However, the most far-reaching assaults on the Elementary and Secondary Education Act during two days of debate were made on the controversial impact aid program.

Most of them were directed, often in caustic tones, against the millions of dollars wealthy suburban school districts in the Washington area get under the program.

Impact aid, first enacted in 1950, is designed to ease the burden placed on school districts by government employes who work at tax-exempt federal installations and military bases.

But it has grown to a program that is estimated to cost almost $2 billion a year by 1983.

Late Wednesday night, the Senate passed two ammendments that rewrote the formula for impact aid involving children of federal workers who move from one school district to another, and eliminated the children of postal workers and students who live in public housing projects from the formula.

Virginia schools would lose an anticipated $471,000 a year by the cut, those in Maryland $735,000. No figures were available for the District of Columbia.

Yesterday, a third amendment, introduced by Sen. Henry Bellmon (R-Okla.), opened up the possibility of far greater cuts in aid for suburban school districts.

The measure, adopted by a surprising 57 to 35, would eliminate the three-tiered system used to allocate impact funds.

Washington suburban schools have traditionally received bonanza impact aid payments because they fall in the second, rather than the third tier, of the system - one that allocates payments bases on the number of children whose parents work on government property and live where they pay taxes.

Sen. William Proximire (D-Wis.), charged that Fairfax County, one of the richest countries in the nation, is eligible to receive $11 million in federal support under current law because of the tiering system.

The Bellmon amendment would place all children in the same pot. This would allow congressional Approiations committees to target the aid to districts they consider most needy.

In other action late Wednesday, the Senate defeated, 60 to 30, and attempt to funnel, for the first time, $2.5 billion to private and parochial schools over the next five years.

The Elementary and Secondary Education Act was first passed in 1965 as part of President Johnson's Great Society program. Since then, it has become the cornerstone of federal aid to education, contributing an estimated 7 percent to the budgets of the nation's schools.

The majority of its funds, $27 billion over the next five years, would go to help disadvantaged children in economically strapped school districts.