As far as I know 「なさい」 is the imperative form of 「なさる」. So why does 「お帰りなさい」 mean "welcome home"? Wouldn't it mean something like "please return"? If it was just 「お帰り」, I could understand it as a mean of taking notice of someone's return.
I was looking at this question and there it's explained that 「お帰りなさい」 takes the same form as 「ごめんなさい」 and 「お休みなさい」, but the translations "please forgive me" and "please rest" actually make sense in the context they're used.
According to this link, it's an abbreviation of 「(ようこそ)お帰りなさいました」. Another person suggests the origin 「よくお帰りになりました」. I'm not sure which one matches the meaning better.
I'm especially confused because 「お帰りなさいませ」 seems to be an acceptable greeting as well. And isn't 「ませ」 also imperative?