The short answer is that the USPS is not a private corporation for exactly the reason you state; delivering the nation's mail is not a profitable enterprise. So, nobody else wants to shoulder that particular burden.
Oh, other companies will definitely chip away at the market of mail and parcel delivery, where there is money to be made in various niches. Small-package delivery, courier services, overnights, etc. When it's larger than a first-class letter, and/or absolutely has to be there on time and in good condition, that's where people are willing to pay the premiums that make the service profitable, because they see the value added to the basic service of getting something from here to there. The USPS then has to compete against these other services on price, lowering its margins in these value-added subsectors, reducing its ability to offset losses in its "core" business of letter-carrying.
Now, that doesn't really answer the question of why the basic service of letter-carrying is so unprofitable. The answer to that is more complex and more than a little political (so you're in the right place). At its most basic, the problem is a similar one to most public utilities and services; the ability to meet the infrastructure costs required to reach absolutely everyone, no matter how remote or inconvenient.
This is a deceptively simple mandate, that belies most of the mammoth cost of the U.S. Federal Government. It's the Pareto Rule at its finest; 80% of the time/money/effort is spent on 20% of the finished product. It's easy, and therefore cheap and profitable, to provide things we consider basic services to about 80% of Americans that live in or close enough to a population center that this denser infrastructure can handle their demand at a feasible maintenance cost. Running electrical lines, a water main, sewer conduit and fiber-optic cable twenty miles away from the nearest connection points out to one customer out in the boonies inflates the costs of this infrastructure considerably, especially when you multiply that by the roughly 72 million people in 25 million households making up the other 20% of the nation's population.
Most for-profit service providers, even of what we truly consider essential services like electrical and water, simply don't bother trying to reach anyone they can't get to profitably. Certain electrical delivery providers specialize in rural power grids, and they charge through the nose for the longer drive times and higher poles-per-customer count of their service areas. If you're not close enough to a municipal water infrastructure, you get your water from a well. If you're not close enough to get minimum guaranteed speeds of a broadband provider's lowest service level, they simply say you can't get their service. Who's gonna make 'em try? And bus service? To your podunk neighborhood? Pfft.
The USPS, on the other hand, has not had the option to say "no we won't" on questions of providing their service, for all but the very most rural routes. Only the very least-populated ZIP codes, maybe a dozen people in hundreds of square miles of ranchland, have "office service only". Everyone else gets at least a community mailbox (though that's all USPS will do for new neighborhoods built after 2018), if not curbside or front-door service (grandfathered indefinitely where it exists).
That mandate to be able to deliver at least to the vicinity of every resident of the United States has remained, even as the volume of items to deliver has steadily dropped in favor of much lower-cost ways to transmit a message. Phone calls, and then e-mail, have made most uses of the age-old practice of hand-writing or even typing a letter obsolete. The USPS handled about 52 billion pieces of mail in 2020. Sounds like a lot, until you realize 129 billion emails were sent the same year, and about 2 trillion cell phone calls were made. The USPS, in an alternate universe where the Information Age never arrived, would have its hands full. As it is, the USPS still has to run the same routes to get what letters it does receive to their destinations, but it's getting far less money in stamp revenue to run those routes.
Imagine a bus service that was required by law to run routes with a stop at the front door of every single house in the United States. Every day. It might take a few days for you to get where you're going, and you might not be very comfortable on the way, but you'll arrive exactly where you needed to go in one piece. Then imagine that this service costs its participants fifty-five cents a ride. Then, say - with a straight face - that this service must turn a profit. Yeah, I couldn't do it either. That's the job of the United States Postal Service, and the expectation of its customer base. There are a lot of other reasons nobody else wants this job, but that should be sufficient for a free answer on an Internet site.