There are at least three significant roles that the United Nations plays in creating a peaceful (or at least more peaceful) world.
First, the UN sometimes sends peacekeeping forces to places where conflict is occurring. These peacekeeping forces are armed, but are not supposed to be there to fight. Instead, they get between opposing forces and prevent them from fighting. Alternatively, they might serve as security forces to protect people who might otherwise be targeted by fighters. These peacekeeping forces are perhaps the UN’s most visible contribution to world peace.
Second, the UN helps to prevent conflicts from occurring in the first place by promoting international law and international dialogue. Because of the UN, countries have a place where they interact with one another in peaceful ways. This helps to create habits of dialogue and peaceful working out of problems rather than habits of armed conflict. The UN also promotes treaties between countries that do things like settling disputes about territory. These treaties help to prevent conflicts from arising.
Finally, the UN can sanction countries that act in ways that are likely to disrupt the peace of the world. The threat of economic sanctions or even of military action authorized by the UN can help prevent countries from disrupting world peace. For example, we can argue that UN-backed sanctions have helped cause Iran to negotiate with regard to their nuclear program rather than simply forging ahead with it and bringing about a threat of serious war in the Middle East.
In all of these ways, the UN can help promote peace in the world even though it cannot ensure that peace will always prevail.