家: why is a home a place for pigs?
Speculations as to why pigs rather than cows form part of the character meaning home comes from some misunderstandings about the characters. Specifically,


「家」 contains 「豕」 as a corrupted phonetic component rather than a semantic component;
「牢」 did not originally contain 「宀」, which is a corruption of a drawing of an animal pen.


Shuōwén's explanation of 「家」 is very close, and it traced the source of the phonetic hint of the character correctly.



商甲甲207合集20268

「家」 (Baxter-Sagart OC: /*kˤra/, home/dwelling) was originally comprised of semantic 「宀」 (building) and phonetic 「」 (also /*kˤra/). In the character 「家」, 「」 was very early on corrupted into 「豕」, leading on to the modern form.

商甲乙1047合集13584西周金毛公鼎集成2841秦簡法106睡虎地秦簡今楷　



「」 (male pig) was originally a picture of a pig 「豕」 with an emphasised reproductive organ, and this word is now written as 「豭」. The glyph evolution compared with 「豕」 is as follows:

商甲京津1048合集15346西周金頌鼎集成2829篆彑部說文解字隸定　

商甲佚43合集20723西周金圅皇父簋集成4141篆豕部說文解字今楷　

Yes, Shuōwén is a source of some egregious graphical corruptions, and it simultaneously remains as one of the most important sources of modern character standardisation. It is a good starting point for character analysis that shouldn't at all be relied on.

Shuōwén's explanation,


  “家，居也。从宀，豭省聲。”
  
  「家」 means dwelling, and is comprised from semantic 「宀」 and abbreviated phonetic 「豭」.


correctly determined the vocabulary source of the phonetic hint, but did not correctly determine the actual character representing the vocabulary source.

The other explanations which interpret 「豕」 as a semantic hint are (in my opinion) rather far-fetched, although these explanations will pop up everywhere in more conservative accounts of the character. At the very least, the non-association of characters for non-pig animals with the character for the meaning home/dwelling strongly suggests the importance of the phonetic role of 「」.



Finally, 「牢」 did not originally contain 「宀」.

商甲摭續90合集33631

The original character was a picture of an animal pen, and sometimes, 「羊」 (sheep), 「馬」 (horse), or 「牛」 (cow) was added to the character:

商甲乙1983合集903商甲1.522寧滬新獲甲商甲甲392合集33314

The form with cow is the shape which has survived ...

西周金貉子卣集成5409

... and the animal pen component was later corrupted into 「宀」 (building).

戰國・楚簡2.77包山楚簡秦簡日甲65背睡虎地秦簡今楷　



References:


黃德寬《古文字譜系疏證》
季旭昇《說文新證》
小學堂
國學大師


郭沫若《甲骨文合集》
中國社會科學院考古研究所《殷周金文集成》

中國哲學書電子化計劃


宋・徐鉉等奉敕校定　漢・許慎《說文解字》