I wonder what made you pay attention to that phrase, but here is what I found over the internet.^^
Firstly, there might be other theories, but the internet says it comes from the number "천만(千萬,ten-million)"
The number, "천만" is pretty big meaning there are few possiblities to happen, so that we can hardly get something involved in the number like the jackpot in a lottery or casino.^^
Some say it just comes from an interjection "천만에" and "천만에요" is a form with "-요" which indicates the polite ending.^^
When we say "천만에요" in response to "고맙습니다" or "감사합니다", it implies that "I think I don't deserve to get that" because it's too big for me to accept^^
There is another phrase related to "천만".
It is "천만다행(千萬多幸)" and "다행" means "lots of luck" or "to be lucky(다행이다)".
For example,
무사하다니 천만다행이네요.
Thank God you're safe.
천만다행으로 아무일도 일어나지 않았다.
Luckly, nothing's happened.
천만다행이다!
What a relief!
천만에, 진심이야.
Not at all, I mean it.
You're quite welcome.
천만에요.
= 천만의 말씀입니다.
Here is one more example,
천부당 만부당(千不當 萬不當),
in here 부당(不當) means either "it doesn't make sense" or "to be unfair".
With "천"and "만", it can be "That's absolute nonsense" or "It doesn't make sense at all".^^
^______^
Extra information.
The thing is that we seldom use that idiomatic phrase in conversation.
I think, as you know, it is more often found in textbooks or it is appeared in dramas or films in a humorous or sarcastic way.
Putting one more example,
we have got "천만(千萬)의 말씀 만만(萬萬)의 콩떡" meaning "It is absolutely impossible to happen","No way" or "don't even think about it".
I think it also shares the same idea as "천만에요".