This is a question whose answer is debated among scholars of international relations.
In theory, the United Nations was supposed to prevent wars from occurring. It was supposed to do this by providing a place for countries to talk to one another rather than fighting. It was also supposed to do this through "collective security," which is the idea that all countries will come to the defense of a country that is attacked. Clearly, the UN has not been able to prevent all wars since there have been many wars since the UN was created.
So what does the UN do to contribute to peace? Some international relations scholars say that the UN contributes to peace by setting up systems in which countries have a great deal of contact with one another. The various UN organizations allow countries to work together towards things like eradicating various diseases or trying to protect the environment. Scholars argue that all of these interactions help to prevent conflict. The interactions make the countries less likely to fight one another because they are used to cooperating.
In this way, scholars think that the UN has contributed to world peace in an indirect way. It has helped countries become more used to interacting peacefully and has thereby stopped them from fighting. Clearly, this has not been successful in all cases, but it is said to help make the world more peaceful.