Here is an example of an interesting play with some bad luck mixed in for good measure.
The umpire did a fantastic job of seeing the ball hit the runner and calling him out. I could hardly see the ball hit the foot in slow motion. He got it in real time. Those guys are really, really good.
As far as the rule goes, the reason a runner is out when getting struck by the ball is technically he is interfering with a fielder. Interfere and you are out.
There are some exceptions to the rule. If a ball deflects off a fielder and then hits a runner, the runner is only out if he intentionally contacts the ball.
If the ball passes directly through or by a fielder (as in within a step), hits a runner, and no one else had a chance to field it, the runner is not out. The logic is the runner cannot interfere if the ball has already passed by or through a fielder.
The rule is a little different in high school. If the ball hits a runner behind any fielder (even it did not pass him within a step), the runner is not out unless another fielder had a chance to get an out. In other words, if the infield is playing in and a ball hits a runner, that runner would not be out.
In all instances and codes, the ball is immediately dead and the batter is given first base and awarded a single. In fact, a famous trivia question of how does a team get 6 hits in an inning and not score hinges on the last out being of this type.
It does not happen often. I cannot remember calling this in my time as an umpire. But, I will be prepared to rule when it does.
A ball hitting a runner is covered on page 54 of RuleGraphics.