Why did the League of Nations fail while the UN endured and has been somewhat successful in promoting world peace?
We cannot know the answer to this question with certainty. When it comes to historical questions like this, we cannot run experiments to determine exactly what factor causes a particular historical outcome. Instead, we can only speculate. I would argue that the United Nations succeeded where the League of Nations failed because the major countries of the world had more incentive to keep the peace after WWII than they did after WWI.
Groups like the UN can only succeed if their members want them to succeed. They have no real powers of their own to force their members to comply with their wishes. Therefore, they have to hope that their members are really committed to their survival. This was much more true after WWII than after WWI. I will lay out two reasons why this is so.
First, WWI left a number of countries relatively strong and relatively unhappy. Germany was defeated in WWI but was not devastated. It was angry about its treatment in the Treaty of Versailles and it had the ability to easily rebuild its military power. Italy and Japan were on the winning side in WWI, but did not get as much as they wanted in the peace treaties. All of these countries were upset with the status quo and potentially able to do something about their anger. After WWII, these countries (particularly Germany and Japan) were so thoroughly defeated that their people had no desire to try to go to war again. Thus, there were not really any major powers after WWII that were strongly dissatisfied with the status quo.
Second, the potential costs of a Third World War were so high that no one was willing to risk setting off such a war. Both the Soviets and the Americans knew that a war between them could easily become a nuclear war that would threaten the very existence of both countries. They were therefore highly motivated to avoid going to war.
These two factors meant that, after WWII, no major powers were strongly motivated to break up the status quo by starting another large-scale war. Therefore, it was much easier for the UN to exist since its mission was to maintain the status quo.