In 2010 Boeing began its CST-100 program, a commercial crewed capsule program financed mostly by Boeing. In 2014, NASA choose Boeing's the CST-100 (rebranded to Starliner) and SpaceX's Dragon as the USA's solution to crewed space access. At that time, I believe NASA wanted its eggs in more than one basket--not a bad idea. Mr. Musk developed his basket years ahead of Boeing who had a head start, while Boeing followed the typical government contract timeline of slow development, cost overruns, and delays.
At least that is my recollection, and I admit to being a fan of SpaceX.
One important difference between a risk-taker like Musk and the standard military-industrial complex, is Musk wasn't afraid to fail where only hardware was at risk. Falcon failed many times, and each time, Mr. Musk took it as a learning experience. Boeing was terrified of a PR disaster, and even so, OFT-1 launched into the wrong orbit and never docked with the space station. The capsule was recovered successfully. Remember too, in less time than Boeing developed the Starliner crew capsule, Musk expanded the Falcon launch system, and developed a Dragon cargo module and a Dragon Crew module.
I'll be watching the Starliner crewed launch this evening at 10:35 pm EDT. NASA TV. Space.com has a link.