Making discrimination illegal only means that the people who wish to discriminate are more careful about not being caught...
No, it also changes the attitude. People do things because they think it's OK to do them. It's legal, so it can't be wrong. Being illegal means they stop thinking it's OK.
Let's say you are in HR. You managed to get someone sacked for being gay, even though this is not company policy. Your boss finds out. You could say "well, it's not illegal; I thought this was fine" and keep your job. Being illegal, your boss says "we just caught you doing something illegal that could be very costly for the company, so pack your stuff".
Or the other hand, your boss tells you to sack someone for being gay. Being legal, you can't refuse. Being illegal, you refuse, and if your boss sacks you you can sue him for tons of cash for being sacked for refusing to do something illegal.