I think the important thing is to realize it's a hail mary. The average outcome of using Hocus Pocus is bad so in even or winning positions it's a mostly bad decision to use Hocus Pocus, but some of its outcomes are very good (super mushroom and invincibility effects are both much better than anything else in your kit). It makes sense to use Hocus Pocus when you're losing to such an extent that your probability of winning via conventional play is lower than the probability that Hocus Pocus will do something to drastically shift the game in your favor.
Given that the two overwhelmingly good effects add up to a 6.1% chance of happening, I think it's almost always going to be about the following situation that using Hocus Pocus could be a rational decision. You and your opponent are both on last stock. You are at a very high percent with low MP. Your opponent is at a very low percent and not in an otherwise precarious position (they aren't off-stage or anything). You will almost always lose from this game state conventionally since you have limited options, must do a lot more to win, and will lose to the next kill move, but you're just close enough to "in the game" for invincibility/super mushroom effects to let you steal the game if they happened. In this state, getting the full MP restoration may also let you offer further resistance, and you might just use some random other spell that is expensive with a useful effect like Kaboom so there's a lot of secondary ways it can at least help you with the odds of it going poorly being mostly unimportant (because your baseline assumption is that you lose).
The other much rarer situation it might make sense is if you survive to a truly obscene percentage. Like lets say you are also running low on MP and you've somehow survived to 210% on your first stock while the opponent is on the second. At this point, non-kill moves will kill you so you have really almost nothing left you can do to extend this stock, but you get a chance to use Hocus Pocus, and hey the invincibility star effect might let you do more with an otherwise dead stock. This is very rare (even at 150% I'd rather force my opponent to land a kill move than gamble if I'm ahead so you need the rare stock where your opponent truly just cannot end you), and if I have a lot of MP, I'd rather just cycle for better direct options or camp with Frizz at over 200%, but if the end is truly here for a very well extended stock, there's a thread of logic of just going for it when the menu by sheer luck gives you Hocus Pocus.