Firstly, it obviously wasn't an illusion. Thanos uses the Space Stone he took out of it on multiple occasions, including almost straight afterwards. Also he wouldn't have been able to Snap if that Stone wasn't real or was an illusion.
Making something invisible or hiding where something is falls under his powers of magic/illusions. We see him do it various times throughout the MCU. We see it in Thor: The Dark World when Loki is in the cell at Asgard disguising what he looks like and where he is; we see it in The Avengers when he kills Coulson and it is also seen in Thor: Ragnarok a few times when he tries to betray Thor. All in all he can make it invisible (or an illusion so it looks like nothing or air or whatever) because that's what he does.
Note in a similar sense we also see Strange make the Time Stone invisible and reveal it again when he hands it over to Thanos later on on Avengers: Infinity War.