What on earth does חס ושלום mean literally, or what is its etymology? Why do people use that phrase in particular to "ward off" bad things? (That last part of the question is not asking whether saying חס ושלום works; nor is it asking what saying חס ושלום is supposed to accomplish. All I'm asking here is why this phrase in particular is used.)
Taking a quick look at wikipedia here:
"Chas veshalom," (Hebrew: חס ושלום, ח"ו) - Heaven forbid, lit. compassion and peace
Another variation: God forbid.
Or to put it another way (from here):
may God bring mercy and peace upon us to prevent this from happening
For the second question (why say this): What else would/should you say?
חלילה is a Biblical Hebrew word meaning outside, foreign, profane. (Compare to חולין.) It can be, therefore, used as a sort of interjection, that it should be foreign, profane, to take such an action. In response to Yosef's steward's accusation that they stole the goblet, Yosef's brothers say: ז וַיֹּאמְרוּ אֵלָיו--לָמָּה יְדַבֵּר אֲדֹנִי, כַּדְּבָרִים הָאֵלֶּה; חָלִילָה, לַעֲבָדֶיךָ, מֵעֲשׂוֹת, כַּדָּבָר הַזֶּה. which mechon-mamre renders as: And they said unto him: 'Wherefore speaketh my lord such words as these? Far be it from thy servants that they should do such a thing.
חס is both a Hebrew and Aramaic word which means mercy, to spare something. For instance, in the Tosefta, שחס המקום עליו. Or in Yerushalmi, חס הוא אדם על כבוד אלמנתו. Jastrow lists it as both Hebrew and Chaldean (=Aramaic). An example from Tanach is in Yirmeyahu 13:14: פסוק י"ד: וְנִפַּצְתִּים אִישׁ אֶל-אָחִיו וְהָאָבוֹת וְהַבָּנִים, יַחְדָּו--נְאֻם-ה; לֹא-אֶחְמוֹל וְלֹא-אָחוּס וְלֹא אֲרַחֵם, מֵהַשְׁחִיתָם. "I will not spare and I will not have mercy."
When someone wants to say that something terrible should not happen, they may search for words that express different aspects of the idea, and form the idiom out of this. (A sort of hendiadys, perhaps, in which there is a conjunction, but both words function to establish the one idea.) Chas veShalom = mercy and peace, which is what there should be, for this should not happen. Or Chalila vaChas, far be it, and He should spare.
They are then, not, etymologically, the same word.
As Dave pointed out in the comment section to the other answer, Rabbi Eliyahu Bachur, in Tishby, writes as follows:
Thus, every Biblical instance of חלילה is translated in Targum as חס. That does not necessarily make them the same word, with a simple reduplication in the phrase. It is just that חלילה does not occur as an Aramaic word, and so Onkelos chose the closest idiomatic expression. Putting them together might be a hendiadys in the same way we observe for chas veshalom. On the other hand, maybe it is a reduplication. That this translation occurs consistently might have made them identical in speakers' minds. I lean towards the former, but can grant the latter possibility.
See also Jastrow's discussion here:
More concise answer: It is a pleading imperative to heaven: "SPARE US, AND KEEP US WHOLE!".
literally: sparing and well-being/wholness [for the speaker] -
The phrase is two nouns joined by the conjunction vav. As it is an exclamatory, pleading phrase. The subject (Heaven/God)is implied, and the object (the speaker pleading/recipient) is/are implied. Each noun is a requested state of things or result.
Looking at the etymology of the root (shoresh) of each noun is helpful.
The lemmas of each word
literally to spare, figuratively to pity. To demonstrate the range of the lemma, consider that it can even figuratively be translated to be overly-concerned about.
וְעֵ֣ינְכֶ֔ם אַל־תָּחֹ֖ס עַל־כְּלֵיכֶ֑ם כִּי־ט֛וּב כָּל־אֶ֥רֶץ מִצְרַ֖יִם לָכֶ֥ם הֽוּא׃
And never mind (i.e. do not fret over/spare your belongings; leave them off) your belongings, for the best of all the land of Egypt shall be yours.’”
Genesis 45.20 JPS
(שלום)שׁלםThis lemma literally means to be completed/complete or whole. Figuratively it means to be kept intact, untouched, nothing taken or missing, thus safe, or in good condition. The english hendiadys and idiom "safe and sound" does well to point to the idea behind this root.
וַיֹּ֥אמֶר לָהֶ֖ם הֲשָׁל֣וֹם ל֑וֹ וַיֹּאמְר֣וּ שָׁל֔וֹם וְהִנֵּה֙ רָחֵ֣ל בִּתּ֔וֹ בָּאָ֖ה עִם־הַצֹּֽאן׃
He continued, “Is he well?” (literally: the wholeness/wellness is to/for him?) They answered, “Yes, he is (literally: they said, "wholeness/wellness"); and there is his daughter Rachel, coming with the flock.”
Genesis 29.6 JPS
וַיָּבֹא֩ יַעֲקֹ֨ב שָׁלֵ֜ם עִ֣יר שְׁכֶ֗ם אֲשֶׁר֙ בְּאֶ֣רֶץ כְּנַ֔עַן בְּבֹא֖וֹ מִפַּדַּ֣ן אֲרָ֑ם וַיִּ֖חַן אֶת־פְּנֵ֥י הָעִֽיר׃
Jacob arrived safe (literally: whole/nothing-missing/intact in the city of Shechem which is in the land of Canaan—having come thus from Paddan-aram—and he encamped before the city.
Genesis 33.18 JPS