Anything is used when you don't know if the thing exists.
"Is there anything in the box"
It can be used when you're vague about what you want.
"I'm so hungry, I would eat anything right now"
It can also be used with a negative
"I can't eat anything at the moment. I'm on a diet"
Nothing is when you know the subject doesn't exist.
"There is nothing in the cupboard.. I'm so hungry"
You can use anything in that sentence, but it needs a negative to work. So:
"There isn't anything in the cupboard" and
"There is nothing in the cupboard " both make sense
In short: anything=any thing nothing=no thing