How is it "immoral"? First of all the law isn't against "thought" - stupid prejudice; it's about "deed" - actively discriminating against someone for reasons irrelevant to the job. We legislate against deeds all the time. Murder, for instance, is mostly illegal. You can think about murdering someone, but you can't take actions that might lead to that result, i.e. hiring a hitman, firing a gun at someone, stabbing someone in the neck with a pencil, etc.