I'm confused. Why would you offload it if you thought it was a good investment?
The short answer is to free up money to make other investments.
The longer answer is that banks generally have policies about how concentrated they can be in individual borrowers, industry sectors, geographies, etc. That is why you rarely see a single bank take all of a very large corporate loan. They syndicate it out.
Banks like good investments, but they like being paid fees more
They make money as middlemen, not the ultimate holders of debt.
They take a cut / fee for financing the debt deal and hold the debt short term. They can't do another deal (simplifying the situation) until they offload the risk. Their business is in their percentage for arranging deals, not in getting paid back over 50 years.
its a different business model? IBs dont generally hold debt to maturity. they underwrite the debt then gradually sell down in the weeks/months following the deal. their business is making money on the spread/underwriting margin.
Massively not an expert, but at that level, things are not a binary "good/bad investment". Financial institutions have policies regarding finely sliced debt types, ratios, risks, lengths, sectors, etc.
I personally think it's all hugely overcomplicating things but that's the way modern world works.
(until it every now and then, on regular intervals, doesn't:)