I hear people say:
"Mein lieber Scholli, das war knapp!"
What does "Scholli" mean in this context? Is using this idiom in any way offensive or insulting?
Nice Question, you never think about those if you are just familiar with them. de.wikipedia.org has another explanation: https://secure.wikimedia.org/wikipedia/de/wiki/Mein_lieber_Scholli
"Die andere Theorie besagt, dass Scholli auf eine reale Person zurückgeht, nämlich auf Ferdinand Joly" According to Wikipedia he was a vagrant in Austria who lived a very own kind of lifestyle.
And to your Question, no it would be in no way offensive to use this. Maybe some people would find it funny to hear a foreigner say this (even for German people this is not a common expression, at least not for my age).
According to Duden Online
is a colloquial expression of astonishment, admiration or relief.
It's derived from the French word "joli" which means "pretty/cute" or "nice".