how many people that train to become pilots actually fail the course?
Define 'the course'. Integrated? IR training? ATPL groundschool? My gut feeling is that a very high proportion of those who start out with ambitions to be a commercial pilot will never make it. Something in the order of 90%. The reasons are many and varied, and
flyhighspeed300 sums up the situation nicely, but money is a big, big factor, along with determination, luck and timing.
Remember that flying schools generally find it hard not to accept people's cash, regardless of their lack of ability. Thus, those with the deepest pockets will generally end up with a CPL/IR eventually. (I know one guy who sold his flat to finance a 'one and only, all or nothing' attempt at the IR, struggled with the course and simply ran out of cash, and another with seemingly bottomless pockets, who finally managed to pass the CPL at the fifth or sixth attempt). Whether these people will ever get a job at the end of it is another question.