Theseus
¥
The 'why' here in front of 'thank you, kind sir' is an exclamation of surprise, as if a woman did not see coming whatever she is thanking you for, and she is using old-fashioned mock gallant language for humour or emphasis. The idiom imitates an archaic mode of speech and it is a 'lady' being a bit old-school with her language as if she is delighted by the action of a gentleman paying court to her (this phrase has been revived and is currently somewhat trendy).
--Your fascinator looks fantastic!
--Why, thank you, kind sir! :)
--Your fascinator looks fantastic!
--Why, thank you, kind sir! :)