MOSCOW -AP- Mikhail Gorbachev and Boris Yeltsin, lifelong Communists who presided over the party's removal from power, told American television viewers today the Communist system had failed their country. The Soviet and Russian presidents sat beside each other in matching gold and ivory chairs in the Kremlin's glittering St. George's Hall. They answered questions live on ABC television from viewers around the United States, and the show was also broadcast in the Soviet Union. The men addressed the fate of their nation's nuclear arsenal, talked about their religious beliefs and stormy personal relationship, and promised dissidents they could return safely. One of their more dramatic responses came to a question by Los Angeles actor Ben Stein, who asked whether the two leaders believed any country should live under communism. Yeltsin answered first: ''This experiment which was conducted on our soil was a tragedy for our people and it was too bad that it happened on our territory. It would have been better if the experiment had happened in some small country, to make it clear that it was a utopian idea, although a beautiful idea.'' Gorbachev said history has shown that ''that model has failed which was brought about in our country. And I believe that this is a lesson not only for our people but for all peoples. But he added that in other countries, ''the devotion to the socialist ideal has led to very interesting results.'' Yesterday, Gorbachev and Yeltsin worked together to gain approval of an interim government for the Soviet Union and a program to create a new confederation of sovereign states. The new system would end more than 70 years of Kremlin rule under the Communist Party and reorganize the Soviet government to give many powers to Soviet republics. The political upheaval followed an Aug. 18-21 coup attempt by a Communist hard-liners who tried to oust Gorbachev as Soviet president and end his reforms. The coup collapsed, its leaders were arrested and the party was pulled from power. Gorbachev and Yeltsin rose to prominence through the Communist Party, but Yeltsin had resigned from it long before the coup attempt and Gorbachev stepped down as party leader afterwards. A questioner from Atlanta who identified himself as Oleg Myshkin, a defector who said he had had problems with the KGB, was assured by Yeltsin, ''There is no more danger ... please come back.'' Yeltsin said he had met with exiles recently and welcomed them home. ''I said 'well certainly, please come back. Now there's no more danger.''' Peter Jennings, the ABC host, asked the two men how they got along. ''Once upon a time that was a difficult question. A good deal of water has passed through the bridge,'' Gorbachev said. Yelstin said: ''Yes, our relationship has not been an easy one. There've been dramatic times and there've been normal and businesslike times. ''There have been times when Gorbachev thought I was a political corpse ... But somehow we've adjusted, and particularly after recent events after the coup, President Gorbachev has changed very seriously.'' From Miami, a Cuban exile asked whether the leaders foresaw the withdrawal of military hardware from his former land. Yeltsin said, ''I think that the process has begun and it must be continued. Gradually the troops must be moved out.'' Gorbachev, however, struck a different note, saying that the two countries have ''mutually beneficial (relations) in an economic sense. ... I believe we don't intend to alter our relations in a different direction.'' A Ukrainian Catholic Church priest asked about the leaders' personal religious beliefs. Gorbachev said it was up to the individual to choose his beliefs, saying, ''I do feel it necessary to add that I am personally an atheist.'' Yeltsin said, ''the services, the ritual aspect - I don't really observe those, although I've been in church quite often, because during the service there's a kind of internal feeling of moral cleansing as it were.'' A questioner from Detroit, educator Carl Gregory, asked who controls Soviet nuclear weapons now and what protections are in place against their accidental use. ''No one should have any anxiety in this regard ... There is a very rigid mechanism that excludes the possibility of any surprises,'' Gorbachev said. From the heavily Russian Brighton Beach section of New York City, a man asked about political prisoners. Gorbachev said that only a few days ago, he and Yeltsin were informed of people imprisoned for ''mixed criminal and political factors.'' He said they hoped to learn more about it. ''We stand firmly that people should not be persecuted for dissidents or for their political views.'' Yeltsin said 21 people were found to have been detained illegally, and ''include those people put in prison for their convictions.'' Gorbachev added the release of six would be sought. The two leaders spoke in Russian and ABC provided an English translation.