THE CHIEF purpose of President Reagan's European trip is to draw the democracies a little closer together, and that's the business that takes him to Spain. This brief visit is a gesture of some importance and represents two days well spent.

During the long years of geriatric fascism under Francisco Franco, Spain remained isolated from the rest of Western Europe. Its neighbors dealt uneasily with General Franco's Spain, and usually at arm's length. But with Franco's death a decade ago, the rest of Western Europe and the United States extended warm support to the new parliamentary government. Eventually it was invited into the two international organizations that have been the foundations of Western Europe's security and prosperity for the past generation. Spain joined NATO in 1982 and will enter the Common Market next January. Mr. Reagan's arrival in Madrid constituted a celebration of Spain's membership in good standing in the association of parliamentary democracies, with all the privileges attached thereto -- and, as Mr. Reagan will probably find the opportunity to remind his hosts, those privileges are not trivial. Portugal has followed a closely parallel path, and Mr. Reagan will make a similar visit there, for the same reason, before he leaves Europe.

For some Spaniards, the case for joining the Western military alliance has never been persuasive. The size of the American military presence in Spain also has been a irritant for some time. Prime Minister Felipe Gonzalez and his Socialist Workers' Party have promised to hold a referendum on Spain's membership in NATO. Although Mr. Gonzalez favors staying in, recent polls suggest that most voters oppose it.

Mr. Reagan isn't likely to attempt much in the way of public persuasion, since he needs to avoid any impression of exerting pressure on his hosts. But his presence is a calculated reminder that, in a dangerous world, it is better to have reliable friends than not. Perhaps it will turn out that the size of the American forces assigned to the four Spanish bases can be negotiated downward, as an indication of American responsiveness on a sensitive point.

There's a nice symbolism to Mr. Reagan's schedule for the next few days. He is to leave Madrid to address the European Parliament -- the Common Market's elected legislature -- before going on to Portugal. The itinerary delicately traces the line between the recent political evolution of the Iberian countries and the democratic traditions represented in the European Community that they are now joining. That's a useful connection for an American president to draw.