Until this year, Iran appeared to most Americans to be a model of stability headed by an iron-fisted monarch determined to use his oil wealth and authoritarian leadership to modernize the country.

There were sporadic student demonstrations, mostly overseas, against Shah Mohammad Reza Pahlavi, but that was a minor irritant for a country bordering on Iraq, Turkey and Pakistan, where unrest or coups have been the order of the day.

For the last 10 months, however, Iran has been the scene of almost daily riots, strikes or protests with a real potential for civil war in the offing. All this is designed to overthrow the shah - the man who had provided land, much of it his own, to his people, unshackled women and was portrayed by many, including himself, as the Great Modernizer of a backward land.

How did all this happen, and how could our perceptions of the country have been so wrong?

Some of the answer lies in the nature of the Shiite Moslem faith which claims the allegiance of 90 percent of the country's 34 million people. And much involves the nature of the Shah Mohammad Reza Rohlavi's rule, since Iran represents virtually a classic test case of how people react to repression.

In a peculiarly Iranian sense the shah manages to be both an autocrat and a liberator. From a Western viewpoint, elements of democracy and freedom are hard to find in the shah's Iran, but then they are exactly widespread institutions in that part of the world.

There is no question, however, that under the shah Iran has made great strides toward modernization and eliminating some of the heritage of the past. The country has embarked on a vast industrialization program, has quadrupled its per capita income since the 1960s, has doubled the literacy rate and has markedly improved health care.

The United States has been the major supporter of the shah, selling him billions of dollars worth of arms and industrial equipment and providing about 45,000 Americans to help train Iranians. With a 1,500 mile border with the Soviet Union and as the world's second-biggest exporter of oil, Iran plays a key role in U.S. strategy for the area.

The United States has regarded the shah, 59, as indispensable, and he has been happy to make that a self-fulfilling prophecy.

The government claims that the opposition mainly stems from conservative Moslem clergy who oppose the shah's emancipation of women and seizure of church-owned property. The real reasons, however, appear to go much deeper and are familiar in the West: unfulfilled economic expectations and lack of political freedom.

To this mix, however, one must add something distinctly Iranian - the grandiose fantasies of the shah. He has declared the aim of making Iran one of the world' top five economic powers by the turn of the century.

The shah ignored one important ingredient in his drive to remake Iran in a generation. Until a decade ago he had a population that was more than 80 percent illiterate. Even today, after years of a much-publicized literacy program, illiteracy is still estimated at 60 per cent.

Still, for a while it looked as if the country had things going its way. The quadrupling of oil prices after the 1973 Middle East war brought undreamed-of wealth.

The shah embarked on a massive industrialization program, including nuclear power, and gave the military, the key institution through which he is now maintaining power, virtually carte blanche to buy equipment. U.S. arms sales to Iran soared and are well over $10 billion in this decade.

As a result of the boom, millions of people, mainly peasant, left the countryside for the urban areas. In the last 10 years the population of Tehran doubled to more than 4 million people.

The consequences of such a mass movement of illiterate, unskilled laborers was virtually ignored. In 1970, a government official proudly declared that the country's 55,000 villages would be cut to 10,000 as the shah attempted to reduce the rural population from 85 percent after World War II to about half by the year 2000.

Drawing the people from the countryside was a massive $35 billion annual development program and the shah's promises of the wonders of Western material possessions.

The trouble was the economy could not keep pace with the program. Inflation soared aboved 30 percent and unemployment more than quadrupled between 1971 and 1976, the latest figures available.

As the economy worsened, the failure of Iran's political system magnified the problems. Over the last 15 years or so the shah had gathered all power unto himself. Opposition political parties were banned; press criticism was not tolerated; opponents were either co-opted or could always be taken care of by SAVAK, the feared secret police.

Such a system does not foster government credibility and in such a situation rumors about government mismanagement and corruption took on credence with a cynical Iranian public.

An apocryphal story about price increases in the Mid-1960s illustrates just how distrustful of the government Iranians are. The story goes that then Prime Minister Hassan Ali Mansour went to Shah to see if he could bring back a "few million dollars of his private funds from Switzerland "to help fund the development program. Instead the shah ordered Mansour to impose heavy new taxes on gasoline and heating fuel, just before winter.

Shortly thereafter Mansour was assassinated and the shah reduced the taxes. There was no question that the taxes did not lead to the assassination, since Mansour was shot by a religious fanatic. But most Iranians got a message: violence was the best way to influence their government.

The peculiarities of Iran's Shiite Moslem religion came to play a key role in this political vacuum. Shiites do not accept the notion of separation of church and state and Iranian governments, long before the Shah, have been plagued by difficult relations with the mosque.

With millions of peasants uprooted and brought to the cities where they brushed with the growing foreign influence in the country, the mosque became their refuge and political outlet in much the same way that Buddhism came to be a political force in wartime South Vietnam.

The shah's liberalization programs of the early 1960s had alienated the Shiite clergy, leading to an unsuccessful coup attempt in 1963.

Ayatollah Ruhollah Khomeini, the key figure in the abortive coup was sent out of the country in exile where the conservative religious leader maintained his leadership of Iranian Smiites and the conservative religious leaders nutured his hatred for the shah and his reforms.

In the ensuing 15 years, Iran has changed radically and it is doubtful that many Iranians would support Khomeini's policies, which include opposition to rights for women and a church veto on legislation. But as the Shiite leader, Khomeini receives the respect of many Iranians, even those who do not practice Islam regularly.

With all other forms of opposition cut off, the mosque became the focal point where a wide variety of dissident elements could coordinate their attacks on the shah. The middle class, with thwarted economic expectations, students opposed to the repression and leftists wanting major changes in economic orientation all grouped under the umbrella of the conservative church, the one organization the shah has been unable to subdue.

On their own, none of the other dissident organizations could cause the government much trouble. Only the mosque, with its traditional hold on the masses, could do so.

With such a disparity of interests among the opposition forces, it is difficult to determine what kind of government they could form if they dicoust the shah, let alone who would lead it.

It is difficult for any meaningful moderate forces to emerge since they are caught between the authoritarian shah, who has not been noted for his ability to compromise, and Khomeini whose basic aim is simply to over throw the Pahlavi rulers.

The shah appears to be torn in two directions as he faces a choice of cracking down on his opponents with a military government - a move that could lead to massive increase in violence - or trying to give real meaning to his liberalization plans by loosening his control and sharing power.

For once, the all-powerful shah seems to be uncertain of himself and is hesitating. He has announced parliamentary elections to be held on a democratic basis in June, but it is questionable whether such elections could be held with the martial law conditions currently in force in much of the country.

Even if he decides at this late date to opt for democracy, there is a serious question whether such a "rush to democracy" could be any more effective than his "rush to Westernization."

History is not replete with examples of Louis XIV-type monarchs successfully relinquishing much of their power voluntarily.