The Just-World Theory/Belief/Hypotheses is an assumption that people eventually get what they deserves. Good people will eventually receive good things and bad people will eventually be punished, hence the world is "just/fair".
One form of defensive attribution is to believe that bad things happen
only to bad people or at least, only to people who make stupid
mistakes or poor choices. Therefore, bad things won t happen to us
because we won t be that stupid or careless. Melvin Lerner (1980,
1998) has called this the belief in a just world the assumption that
people get what they deserve and deserve what they get (Hafer, 2000;
Hafer & Begue, 2005; Lipkus, Dalbert, & Siegler, 1996).
Fundamentally, this belief is motivated by our need to feel secure, to decrease anxiety from our vulnerabilities. After all, if bad things can happen to anyone, they can also happen to me regardless of what I do/don't do. Consequently, there are no guarantee that I'll receive "reward" for doing good.
By using this attributional bias [belief in just world], the perceiver does not have to
acknowledge that there is a certain randomness in life, that an
accident or criminal may be waiting just around the corner for an
innocent person like oneself. The belief in a just world keeps
anxiety-provoking thoughts about one s own safety at bay.
You can imagine that this "randomness" can be overwhelming at times, especially when a tragedy strikes; for example when someone from work/school was raped.
Ironically, those who strongly believe in a just-world tend to unfairly judge that it must have happened because the victim did something wrong, e.g dressed inappropriately, flirting, etc. That way, the person can still believe that this world is fair, and if he/she doesn't do bad things, it will never happen to him/her.
Research by Elaine Walster (1966) and others has focused on such
attributions, which these investigators call blaming the victim (e.g.,
Burger, 1981; Lerner & Miller, 1978; Stormo, Lang, & Stritzke, 1997).
In several experiments, they have found that the victims of crimes or
accidents are often seen as causing their fate. For example, not only
do people tend to believe that rape victims are to blame for the rape
(Abrams, Viki, Masser, & Bohner, 2003; Bell, Kuriloff, & Lottes,
1994), but also battered wives are often seen as responsible for their
abusive husbands behavior (Summers & Feldman, 1984).
...
When something bad happens to another
person (as when someone is mugged or raped), we will undoubtedly feel
sorry for the person but at the same time will feel relieved that this
horrible thing didn t happen to us. We will also feel scared that such
a thing might happen to us in the future. How can we cope with these
fears and worries? We can protect ourselves from the fear we feel by
convincing ourselves that the person must have done something to cause
the tragedy. We feel safe, then, because we would have behaved more
cautiously (Jones & Aronson, 1973).
Does it always apply? No, not for everyone and not in every situation.
It explains one possible way people deal with anxiety of feeling insecure, but not as the only way. I couldn't find any scientific sources, but I imagine that people can see tragedy without feeling any insecurities, or can perceive the world as fair but have an entirely different reaction, or even doesn't see the world as just/fair in the first place.
References:
Elliot Aronson, Timothy D. Wilson, Robin M. Akert. (2010). Social Psychology Seventh Edition. New Jersey: Prentice Hall.