Golfers’ yelling of fore is a way of warning other golfers to watch out for a golf-ball that is hurtling towards them. “Fore” is simply a synonym of “forward” or “ahead” and is just is simpler and quicker way of communicating “watch out ahead”. When a golfer accidentally shoots a ball in the direction of fellow golfers such that they could be potentially hurt by it he should yell “Fore” as a warning.
According to the historians at the British Golf Museum “fore” evolved from another term called “forecaddie”. A forecaddie is a person who escorts a group of golfers in a golf course and points the shot locations of the golfers. If a group member hit an errant shot, he would alert the forecaddie by yelling “fore”.