Warning: I’m not a lawyer.
Suing is expensive. Unless they want to make an example of you (they might, who knows) they’ll send you a cease and desist first. Building a creative work on another company or person’s IP is illegal outside of very specific circumstances, and even in those circumstances (i.e. fair use) you have a legal defense, not a promise to not get sued (a license is literally a promise by a rights-holder to not sue you as long as you follow it’s terms and conditions), so even in circumstances of fair use, they can sue you if they want to and feel that they have a chance of winning.
On top of this, certain types of IP, particularly trade marks, essentially require the rights-holder to use and protect it in certain countries in order to maintain it, meaning they have to take you to court whether they want to or not, which is why you see somewhat silly litigation in the news, like Elder Scrolls vs Scrolls or Sky TV vs No Man’s Sky.
So: it’s not legal, and you could get sued. It’s way more likely that you’ll just get a cease and desist first though. Either way, building your work on another’s IP is like building it on sand, you might have to take it down.
I think it’s always a good idea to ask permission from the rights holder. They might just say no. They might not respond at all. They probably won’t say yes. But I think risking the “no” and having to give up before devoting a lot of time is better than devoting all that time and then having to taken it down. Also, it never hurts, if you do get sued, to have proof of a good-faith effort to get permission that you can point to.
It is pretty much illegal though. So is fan fiction, for the most part.
One more time, though, I’m not a lawyer. I’ve dealt with some IP issues before, but the laws are complicated, so don’t take my rather basic understanding of things as being necessarily accurate.