The story
The opposing senses of the interjection derive from the phrase functioning as an ellipsis of both have no fear ("be assured") and there is no fear of that happening ("it's impossible").
Etymology from Wiktionary, CC BY-SA 4.0.
Today it means: Not a chance, impossible. Full definition →