It's easy.
Luciano went behind Rothstein's back and took a huge loan out from Masseria to buy the heroin. Because of the enormity of the loan, Masseria needed the money back. Rothstein knew this.
So in order to get his hands on the Mellon distillery, Rothstein had his crooked cops arrest Luciano, take his heroin in exchange for a bargain, and then give the heroin to him (suggesting that he knew about their side operation the whole time).
Now Rothstein has the heroin and Masseria has no money. So Rothstein offers Masseria a share of the heroin that HE bought, in exchange for giving up Gyp. Masseria gets a chance to see profit on his investment AND he doesn't have to deal with Gyp, who was waging an unprofitable war.
The only kink was Capone and Chalky killing the fukk out of ALL those men that Masseria ordered back to NYC. That was not part of the plan.
Could be grounds for war in the future.