It's used to describe an expression so I guess it's close to being shocked or frightened from the context it's used in but I don't really understand why it means that.
So a detailed explanation will be much appreciated.
The expression is somewhat similar to English scare the living daylights out of
somebody, with many variations. A quick Google search shows
and other similar constructions.
三魂 refers to the three hun in Chinese philosophy/folk religion or Daoist belief. The three hun make up a person's "essence" (soul, spirit) when they're alive, and go their separate paths after a person passes away:
If the three hun are somehow absent from the body when the body is still alive, then the body becomes a walking corpse (行尸走肉), so the expression 三魂去了兩魂半 means almost frightened to death.
In order to understand it, you need to know these two phrases: 三魂七魄 and 吓得没了魂儿.
According to Baidu, 三魂七魄:
So, 三魂 and 七魄 are necessary for a live person. If you lose all 三魂, then you would die.
吓得没了魂儿 means one is so frightened that he lost his 魂儿(soul) and die. It's actually a figurative speech. They will not literally lose them and die.
三魂去了两魂半 is a similar phrase to 吓得没了魂儿. You can imagine that “三魂去了两魂半” is about one loses two and a half of 魂 given he only has three. Figuratively, it implies that one almost dies of something frightening or scary.
So, 吓得没了魂儿 == 吓死了； 三魂去了两魂半 == 吓得半死 or 吓得要死.