The legal issues are a little complex because there are multiple of them and the timeline is a little bit all over the place. There
have been a few videos made on
YouTube going over what happened. The original series was a joint venture between Scholastic and Parachute Press, who was partially owned by Stine's wife Jane. Both publishers had different rights to the books. Things however seemed to heavily favor Scholastic in terms of marketing and merchandise.
Parachute obviously wanted more and thought Scholastic was hindering their ability to profit off the books. Scholastic obviously didn't want them to have more and thought at times Parachute was overstepping the boundaries of what they had agreed to in contract. Parachute then accused Scholastic of mismanaging the franchise and causing them to miss out on potential revenue. These tensions started boiling and this led to Parachute striking first with a lawsuit regarding mismanagement.
The ghostwriting stuff came about in 1999. In Stine's 1996 contract that he signed with Scholastic, which came after Goosebumps had exploded in popularity, forbade him from using ghostwriters on the main books. While Stine has admitted to using ghostwriters on various projects related to him, in regards to Goosebumps he only used them for some of the spin-off books like the "Give Yourself Goosebumps" game books. His contract allowed for him to do specifically that. He has always maintained he was the sole writer of the main book series, only claiming that ghostwriters may have helped him out with some outlining in regards to the main books.
Ghostwriters that have come forward over the years to discuss their work on Goosebumps have never said that they had written any of the main series books. Only the spinoff books. Literally there has never been any proof that counters Stine's claims regarding how he used ghostwriters in regards to Goosebumps.
Either way, Scholastic decided to accuse him of violating his contract and starting withholding royalties from both Stine and Parachute. Their excuse was that the ghostwriters had caused the decline in the popularity of the books, not the fact that the series had been running for years at that point and the market was oversaturated with Goosebumps books. Scholastic would eventually file lawsuit in early 1999 claiming that Stine had violated his contract. That led to Parachute filing another lawsuit over the withheld royalties and for what they were doing to Stine.
Something also to note about ghostwriters: a lot of Scholastic books have used ghostwriters. Animorphs, which had overtaken Goosebumps in popularity in the late 90s, was heavily ghostwritten. In fact, pretty much every book written by Animorphs author K.A. Applegate during her time at Scholastic was ghostwritten.
If you want my honest opinion on the whole thing, it seemed like Scholastic had deliberately targeted Stine with a super strict contract in 1996 because they were hoping he would fail to meet what was required of him and they would be able to claim universal rights to everything regarding the franchise for a cheap price. When he actually managed to navigate what was asked of him in his contract, they obviously became pissed and decided to accuse him of violating the contract anyway in an attempt to push Stine and Parachute out of the picture once and for all.