One factor is surface area. The more surface area there is, the more gas can exchange between the blood and the inhaled air. As the alveoli become smaller, thinner, and multiply, the total surface area increases, until gas exchange to and from the blood becomes efficient.
Another factor is diffusion distance. The blood, flowing through capillaries around the alveoli, must exchange their gas through the solid walls of the alveoli and the capillaries; they must have solid walls so the blood doesn't escape into the lungs. Because of this, diffusion is not efficient unless both capillaries and alveoli have very thin walls; the distance between the blood and the inhaled air is short enough for efficient diffusion.
Another factor is partial pressure gradients. Gas moves from an area of high partial pressure to an area of low partial pressure. When the blood flows through the capillaries, passing around the alveoli, the blood has a low partial pressure gradient of oxygen and a high partial pressure gradient of carbon dioxide. Each gas moves naturally to the area where the partial pressure is lower, allowing the blood to pick up a load of oxygen for the body to consume.
Distance that the particles travel
Size of partciles
Temprature and conditions