Ordering everything from clothes to furniture online has become commonplace, but do you ever stop to think about how all of those items get to your front door?

Delivery companies build multibillion-dollar networks to distribute packages, including hundreds of aircraft to speed deliveries. Having a large fleet can be a competitive advantage, and that's an advantage FedEx (FDX -2.09%) is trying to maintain. 

Building a fleet to envy
FedEx is trying to build an aircraft fleet that will be the envy of the industry, and it's betting billions that that fleet will give it a competitive advantage. Its latest major move was an order for 50 Boeing 767 freighter airplanes that are estimated to be worth nearly $5 billion after discounts. The new airplanes are expected to replace 56 McDonnell-Douglas MD-11 airplanes that are ending their useful life and have become less efficient than new aircraft.

The purchase will add to (though maybe not significantly) the company's already impressive aircraft fleet. You can see below that it's even bigger than UPS(UPS -1.51%) and DHL's.

 Company

Current Fleet

FedEx 

390

UPS 

238

DHL 

>250

Source: PlaneSpotters.net.

The new aircraft are necessary, as FedEx took a $246 million charge in fiscal 2015 to retire 15 aircraft and 21 engines, and adjusted the retirement schedule of 23 additional aircraft and 57 more engines. Hopefully, the newer fleet will lead to lower costs for operations and less risk of writedowns in the future. 

FedEx's next challenge
What FedEx needs to do now is turn that fleet into a more profitable business, and that's easier said than done. UPS has long had better margins than FedEx, which is why it has a market cap about twice the size of its rival.

FDX Operating Margin (TTM) Chart

FDX Operating Margin (TTM) data by YCharts.

What management is hoping is that lower operational costs will start to bridge that gap. If it does, FedEx could rule the air and get a boost from Wall Street.

Betting billions on the sky
The opportunities and risks for FedEx are enormous considering the growth in online shopping and the shipping associated with it. But spending $5 billion on aircraft is a big risk as well. Management is hoping that this will give the company a competitive advantage, which will lead to stronger sales and higher margins.

Time will tell if the industry plays out that way.

Editor's note: A previous version of this article listed DHL's current fleet size as 25. The Fool regrets the error.