In the "you are welcome" form, you can use it as you would use "Oh don't mention it". It comes from the other usage, which is used to express that something is not realistic/desired: "Ma figurati se adesso mi metto a insegnarti l'italiano gratis", I guess it can be conveyed in English as "But imagine if I'm going to teach you Italian (how ridiculous/inconvenient/annoying that would be)", although in the English world one would use sarcasm instead. In the welcome form, it becomes "oh imagine (if you needed to seriously thank me for this, how superfluous that would be)".