This should apply even to past criminals.
Such laws protect against racism and other forms of discrimination, and they help integrate convicts back into society, at the cost of "commercial freedom".
In jurisdictions with these laws (I know at least one), it's impossible to create, for example, bars only for men or only for women or refuse service to people we don't like (also, because they belong to some group, incl. morally reprehensible groups). There are some hacks around this and exceptions, but generally, it works and solves more problems, than it creates. Private gatherings or clubs are likely ok (nondiscrimination laws should still apply).
UK and US are outliers here with their "can refuse service to anyone" approach.