REPUBLICANS and Democrats could learn a lot from Pennsylvania.In a special election to the United States Senate Tuesday, a little-known Democrat beat a heavily favored Republican. Appointed Sen. Harris Wofford won surprisingly easily over his Republican challenger, Dick Thornburgh. With 97 percent of the vote tallied, Senator Wofford had 55 percent of the vote to Mr. Thornburgh's 45 percent. The impressive win is buoying Democratic hopes nationwide. President Bush, who less than a year ago looked unbeatable in 1992, may be vulnerable on domestic issues. It's "an upset of monumental proportions - the biggest upset in Pennsylvania politics," says G. Terry Madonna, a professor of political science at Millersville University. "This gives Democrats from the top down a lot of hope," says Jeff Eller, a spokesman for the Democratic Senatorial Campaign Committee in Washington. "Our challengers and incumbents are going to take a long look at what happened in Pennsylvania." By winning the seat, Wofford preserves a 57-to-43 Democratic majority in the US Senate. Next year, 20 Democratic senators and 14 Republican senators come up for reelection. To recapture the Senate, the GOP would have to win all the Republican seats and pick up 15 of the 20 seats now held by Democrats - a difficult feat. What makes the Wofford win so impressive is the political disparity between the two candidates. Mr. Thornburgh, a former two-term governor of Pennsylvania and US attorney general under Presidents Reagan and Bush, was a polished campaigner. Early in the race, he held a 40-point lead in the polls. Wofford, by contrast, started out virtually unknown in Pennsylvania. Although he had participated in politics - special assistant to President Kennedy and Pennsylvania's secretary of industry and labor - he had never run for elective office. Pennsylvania's Gov. Robert Casey appointed Wofford to the US Senate this spring following the untimely death of Sen. John Heinz in a plane crash. Although the incumbent, Wofford ran as the outsider and often looked it. He stumbled over sentences and seemed to lack media savvy. But he pounded home his message about the need for change, calling for national health insurance. By last week, three polls showed that Wofford had pulled virtually even. By carefully tailoring his message to worried middle-class voters, Wofford, a former civil-rights activist, successfully broadened his appeal. A key to Wofford's victory was widespread pessimism about the economy, says Patrick Stroh, a political science professor at Carnegie Mellon University. "It's ... a recession that people are viewing almost as a depression," he says. "A year ago, people would have said there's no way that Bush can lose," he adds. That confidence was based on the assumption that the economy would pick up. But it hasn't. "Depending on what the economy does, there could be some serious problems here for the Republicans." Even Democratic strategists caution that the success in Pennsylvania may not carry over to the rest of the nation next year. But it does send a loud message, analysts say. Domestic issues count, especially in states like Pennsylvania, where so-called Reagan Democrats, who voted Republican during the 1980s, may be returning to the fold.