I believe he actually did it for free too as a favor to Quincy Jones who I'm sure most hardcore musicians back in that day idolized.
Probably had no idea that song would go on to be one of the biggest of all-time and the album it was on would go on to be the greatest selling album in the history of the world. That album probably has sold in excess of 100 million units worldwide and generated billions of dollars. Eddie probably should've asked for some royalty fees.....probably cost himself millions of dollars there. Not like he needs the money though- he's probably already rich af but still- homie left tons of money on the table there.
Well, yeah, dead guys don't usually need money.
I would imagine he recorded that solo as a union session musician member, in which case the standard deal is you charge an exorbitant rate for the session block, and then whatever happens, happens. If a song flops, hey, you were paid well for your time. If a song becomes legendary and generates a bazillion dollars, well, you were paid well for your time. Much of the work on that album, and that song in particular (minus the EVH solo) was done by the guys from Toto. It was the same gig for them. If a song featured "Toto" (I don't think any ever did), it would've been some sort of artist collaboration and royalties would be split. But when the individual guys worked as session musicians, they just got what they got like everybody else.
As Steve Lukather, the guitarist on the track doing everything but EVH's solo, and Quincy himself tells the story, Quincy had decided to go for some rock credibility to get MJ some interest with the rock listeners, and he wanted Eddie to deliver that. But he didn't know Eddie so he had to cold-call him. He said he was Quincy Jones and was producing the new MJ album and he wanted him (Eddie) to play on a track. Eddie told him to GTFO and hung up on him. Stunned, Quincy called back....and got the same response. On the third try he understood Eddie didn't believe the real Quincy Jones was calling him. He thought he was being pranked. So Quincy called Lukather, who did a lot of work for Quincy back in those days, who knew Eddie very well, and told him what was happening. After getting done laughing, Lukather called up EVH and told him Quincy Jones has been trying to call you, so you need to stop telling him to f*** off. Eddie claims he turned beet red and sheepishly called Quincy Jones back, full of apology.