Amid warnings that the world faces its greatest dangers in decades, leaders of 41 countries convened here today for a conference aimed at spurring a resumption of the North-South dialogue between the earth's rich and poor nations.

Coming three weeks before a summit conference of 22 world leaders in Cancun, Mexico, the Commonwealth Heads of Government Meeting here will try to produce a consensus to present to that conference as a basis for renewed North-South talks, delegates said. It is hoped that such a consensus would influence President Ronald Reagan, who is due to attend the Cancun conference.

Today's opening session, amid extraordinary security precautions, seemed to reflect a sense among the Commonwealth leaders of global economic tension.

Participants mentioned the recent worldwide stock market plunges and continuing high interest rates in the United States as sources of the unease.

Delegates also appeared anxious about President Reagan's attitude toward the global issues to be discussed at the Cancun summit, notably international trade, energy, the world food supply, raw materials and the international financial system.

Other major issues confronting the leaders here, who represent more than a quarter of the world's population, include negotiations on the independence of Namibia and sports links with South Africa. In a speech at the opening session, Commonwealth Secretary General Shridath Ramphal of Guyana declared that "a situation of crisis inevitably threatens human society" and he compared the situation today to that of the 1930s.

"It is not so very different now," he said. "Next year offers the prospect of more than 26 million unemployed in the industrialized world and vast numbers in absolute poverty everywhere." Yet, Ramphal lamented, it was easier "to acknowledge that the recession is worldwide than to accept worldwide solutions."

The conference host, Australian Prime Minister Malcolm Fraser, also spoke forcefully about a need for progress on North-South issues.

"I am convinced that our generation of leaders will ultimately be judged largely in terms of their success or failure in reconciling the interests of the rich and poor countries of the earth," he said. "In my mind, those who fail to recognize the gravity and drama of the issues disguised by the rather bland term 'North-South dialogue' are guilty of a serious failure of historical imagination."

Another urgent appeal on the same subject came in a joint statement by Ramphal and West German former chancellor Willy Brandt, currently chairman of the Independent Commission on International Development Issues.

However, British Prime Minister Margaret Thatcher took exception to the "dramatic" talk of other leaders on the North-South issues. She said she hoped the Melbourne meeting would "pave the way for fruitful exchanges" in Mexico, but added:

"The solution to our problems lies not in the redistribution of existing wealth-- there just isn't enough -- but in the creation of new wealth."

Fraser indicated that he viewed the Commonwealth as a forum to push for the independence of Namibia from rule by neighboring South Africa. However, Thatcher said the Commonwealth should stay out of the matter, leaving it to a five-member Western "contact group" and the United Nations.

By contrast, Zimbabwe's prime minister, Robert Mugabe, urged the Commonwealth to take a strong stand against South Africa. He also sharply criticized President Reagan's policy toward the country.

"The friendly posture taken by the Reagan administration toward South Africa is a cause for grave concern to the whole African continent," Mugabe said.

Relations with South Africa threatened to inject further divisions into the 10-day meeting as New Zealand's prime minister, Robert Muldoon, said he would raise the issue of a Commonwealth agreement on sporting contacts with South Africa following attacks on his country for allowing a recent tour by South Africa's rugby team. Muldoon argued that his government did not violate the terms of the agreement, and he hinted he might raise human rights questions concerning African countries that sharply criticized New Zealand for the rugby tour