This is a question that there are a lot of arguments about. First we will start with some history. After World War II, Soviets unveiled a new firearm for soldier, the AK-47, which was designed to use 7.62x39 mm. bullets. This caliber was heavily influenced by developments of bullets of similar size in Germany. Meanwhile, NATO forces were using 7.62x51 mm. bullets, based on designs made by the US. Both these bullets pack a punch and have pretty good range. As it happens though, they also produce a good amount of recoil (especially the NATO rounds) and make a gun harder to control in automatic fire mode. One more factor to consider is that most people can't hit anything farther than 300 meters or so and therefore, giving them ammunition capable of firing well past this distance is not useful because they can't effectively use it. Additionally, the US military did some experiments in the late 1950s/early 1960s and determined that high rate of fire was the most important factor in infantry combat. To produce a high rate of fire means that a soldier needs to carry more ammunition. Therefore, the US military settled on a 5.56x45 mm. bullet, based on a .223 Remington cartridge that already existed. The 5.56x45 mm. NATO ammunition is close to half the weight of the 7.62x51 mm. ammo, therefore a soldier can carry twice as much.
As a side benefit, some people claimed that 5.56 is more likely to wound someone and therefore takes more than one person out of the fight because others have to tend to the wounded person's wounds and transport them to get medical attention. This was however NOT the reason why the 5.56x45 mm. was chosen, the main reason was because they could carry more of them. And, the 5.56x45 mm. is deadly at shorter ranges as well.
While the smaller bullet is fairly effective at shorter ranges, it loses some of its effectiveness at longer ranges. This is why some people argue that an intermediate bullet of 6.8x43 mm. might be a better compromise. It has effectiveness up to 500 meters or so and as it delivers about 50% more energy than 5.56x45 mm. at 100-300 meter ranges. However, it doesn't recoil as much as 7.62x51 mm. ammunition and provides better controllability. Also, since it isn't as heavy as 7.62x51 mm. ammo, a soldier can carry a good amount of them around.