They're not barred from competing. They're split into different subsets to more closely match them with people with similar potential exactly to make the races more competitive.
I would have some sympathy for your argument if you argue against womens only races or men only races, but most sports do not arbitrarily deny access to a given group, but split people into groups and try to counter effects beyond competitors control, such as gender, age, so that training plays a bigger role in the results distribution.
The point is that we are seeking to give prices to those who have gotten closest to their maximum potential, not for their genetic starting point or circumstances. Yes, we can not counter everything without splitting things up too much, but we can aim to equalise the playing field somewhat.
This is not discrimination. This is seeking to reduce "unfair external advantage". It's the opposite of discrimination.