The Space Shuttle could have made money as technically it performs very well at delivering large payloads to the ISS (Falcon 9 rockets cost 1.39X more to deliver people and payloads to the ISS according to my table below). The Space Shuttle is probably is not as nimble and adaptable as other smaller systems - both technically and from a pace-of-business perspective. For smaller business opportunities, it would be like trying to use an A380 airliner to serve numerous small rural communities.
In response to @user20636 and @user3049's request for better references, while I do not have additional references for the above table, I do have some newer and more up-to-date sources of information that might be helpful.
The new sources may help answer the original poster's question, "Why didn't NASA use the shuttle to make a profit?" These sources provide some perspective on how much it costs NASA to pay other companies for transportation services to and from the ISS. With that perspective, it becomes apparent that the Shuttle may have been a cost-effective solution to the problem. While I don't think that it was NASA's mandate to "Make a Profit" in the traditional sense, it certainly was their goal to stretch their budget as far as it could go.
If we think of space transportation services as a make-versus-buy decision, then they chose "make". They perhaps profited handsomely (in the sense that they got a lot done with their budget) by making that decision - although I will certainly acknowledge that this is a debatable point. They also partnered up with the DoD which helped them to achieve even more with the same funds.
Ok, the new sources that I'm aware of that are relevant to the table above are...
Adjusting for Inflation
U.S. BUREAU OF LABOR STATISTICS is the traditional method.
NASA has its own way of adjusting for inflation called the
NASAs New Start Inflation Index.
It is important to adjust for inflation if the goal is an accurate apples-to-apples comparison over decadal timescales. It is also important to use a common reference mission. That is, be careful not to compare the cost of resupplying the ISS using the Space Shuttle to the cost of launching satellites to LEO using modern rockets. ISS resupply involves a round-trip that includes additional cost and mass for deorbiting, reentering, safely touching down, etc. It's best to use the same mission for both systems when comparing them.
SIERRA NEVADA CORPORATION,
ORBITAL SCIENCES LLC,
SPACE EXPLORATION TECHNOLOGIES CORP, etc.
For accountants: This approach involves a lot of work but it's more likely to give you ground-truth results if you don't make any accounting errors. You will need to find the ISS resupply contracts including NNH15CN76C, NNH15CN77C, NNJ16GX08B, NNJ16GU21B, NNJ16GX07B, NNJ09GA04B, NNK14MA74C, NNK17MA01T, NNK16MA58T, NNK16MA03T, and 80KSC019F014. (There may be more.) With these spreadsheets in hand, you can tally up where NASA has spent or is spending money on ISS commercial resupply services.
Office of The Inspector General (OIG)
Audit Of Commercial Resupply Services To The International Space Station
Lots of good data in this 2018 report including:
"Dragon 1 maximum combined pressurized and unpressurized upmass is 3,310 kg" (footnote 31 on page 9)
"Dragon 2 Upmass Per Mission ... 3307 kg" (Table 1, page 12)
"Cost Per Kilogram ... $71,800(Projected)" (Table 3, page 21)
NASA Press Release
"NASA Awards SpaceX More Crew Flights to Space Station"
In this press release, NASA says that Crew-10, Crew-11, Crew-12, Crew-13, and Crew-14 flights will cost USD 1,436,438,446, which works out to roughly USD 287,287,689 per flight, or USD 86,873 per kg if you assume the maximum payload of 3307 kg from the OIG report above.
It's probably worth noting that in a big-picture sense, NASA pays more per kg because they also award contracts to other launch providers, such as Boeing and Sierra Nevada. As of Dec 2023, these other providers' launch systems are not in service the way SpaceX's system is. There is also the cost of operating the Kennedy Space Center to consider. I do not have information on how this cost is accounted for but it should be included in a truly comprehensive cost analysis.