The rules require you to have a valid target to cast the spell. It's an explicit requirement for a spell to work. I personally don't agree with RAW, so I do it differently in my game, but thems the rules.
So you can't be like, "Hmm. I wonder if there's something in that empty space over there and cast the spell." You aren't targeting anything. You can be like, "I heard something invisible moving in that direction, I'm going to target it in that space" and miss due to it not being in the space you think the creature is in. You targeted a valid target, but got the space wrong.