This is common advice in Rape Prevention classes. It is classic psychology.

Basically, people are selfish and act with a mob mentality. If you're in a big crowd and get attacked, and yell "Help!", individuals tend to think that someone else will answer the call for help. This is called diffusion of responsibility.

If, on the other hand, you yell "Fire!", people all of the sudden get very worried about their own personal safety and pay attention very well. Once attention is drawn to yourself, the attacker will probably back off or you will be helped.

Now, it is important to note not to do this in very confined areas or areas where people may get really panicked. Places not to do this include airports, airplanes, movie theatres, schools, college lecture halls, et cetera. Of course, you're not apt to get attacked or raped in all of these places, but you get the basic idea.

And, as noded in You can't shout fire in a crowded theater, it is very illegal in some places.