In many ways the United Nations is a product of the Second World War. It took quite a bit of effort to forge the political alliances necessary to build the Allied military force that defeated the Axis powers during this war. Even before the formal surrender of Germany and Japan, it was realized that a long-term relationship should be developed among those countries that participated in the defeat of Facism, and a political solution that had global input needed to occur with the territories captured from the Axis powers.
During the final years of WWII, the name of the alliance had even changed, with the term United Nations being used formally for the first time as the name of the allied nations in press releases and newspaper accounts. While not formally the organization that exists today that is called the United Nations, many of the tasks that are now handled by the various Secretariats of the UN were first started at this time. There was also a strong sentiment among all of the participants of this alliance that they should not repeat the same mistakes that occurred at the end of the First World War, and in retrospect it could be argued that the framers of the United Nations have largely succeeded in that task.
Another aspect of the organization of the United Nations is the need to coordinate new participation in the war. The wartime alliance toward the end of WWII had many new countries willing to participate directly and indirectly in the combat operations, but this requried formal alliance treaties independently with each of the major allied powers and grew more complex as more countries joined the alliance. It was becoming so complex that some otherwise needed wartime supplies were actually refused because of the political bureaucracy that was developing.
Some international agencies such as the International Postal Union and the International Telecommunications Union pre-date the founding of the United Nations as well, but currently receive support from the UN and are considered appendenges to the larger organization as well and are governed under charters issued by the UN. There were also some aspects of the League of Nations that were absorbed into the United Nations, as most of the participants in the older League of Nations were also members of the United Nations as well. This is largely the result of a spirit of cooperation between nations that existed in the years prior to WWII, particularly for issues that didn't seem to have significant differences of opinion on how to proceed but required cooperation and standardization.