This is a huge, huge question. You have to start with: Companies grow in several ways. Companies that are not growing are either stagnant or shrinking. One of the ways companies grow is through M&A, or mergers and acquisitions. Companies also divest assets for a variety of reasons. Sometimes the assets divested are recently acquired assets, sometimes they have been long term investments.
It is my understanding that Roland was an investor in Cakewalk from very early days and the final purchase was made when the Founder of Cakewalk made his exit. Highly likely that arrangement was made well in advance.
Now, music companies in general, record labels, instrument builders, software, publishers et al, have been struggling with a landscape that has changed rapidly and dramatically in particularly over the last 15 years since the dawn of Napster. We have seen record labels reorganize, music software boom and bust, and traditional instrument makers having to deal with a whole host of issues.
So, why did Roland sell Cakewalk? Because Roland thought it would be better for their bottom line. Perhaps they wanted to streamline there business and focus less on the market for DAWs. Why did Gibson purchase Cakewalk? Gibson brands has been acquiring various companies over the last 30 or so years, perhaps Gibson thought a DAW and music software company that they no doubt got for a bargain basement price would be to their advantage.
The problem with music software, or the problem with the music industry in general nowadays is that you only have superstars. If you are not a superstar you have no career. It is a huge problem for fans, record labels, music software, and instrument makers.