I'm going to jump in with a long answer. I don't want you to misunderstand me, so let me be clear first: your boss' idea is a bad idea. It's a bad idea for a lot of reasons, most of which have been addressed in other answers. Here's the biggest problem though:
You're playing by the wrong rules
It sounds like you are in a leadership position in your company and work closely with the CEO. Having been in such a position myself for many years, I want to be clear about one very important skill you need to have to be very successful in such a role: you need to learn to speak the language of business. "This is immoral and I won't do it" is an absolutely useless response when the CEO asks you to do something. If you are going to say that then you need to be okay with the possibility of being fired and you should be frank with your next potential employer about what happened here. It's one thing to say "My boss asked me to do something illegal, and when I refused he fired me" (stuff like that can definitely happen in the USA), and many employers (especially the good ones) will look favorably on such a thing. However, "I disagreed with my boss about something he asked me to do, refused to do it, and got fired" looks a lot less favorable to you. You are insisting that this is immoral, but the reality is a whole lot more fuzzy. As someone who takes morality very seriously I don't consider this to be immoral: just a bad business decision. If your resume came across my desk and you explained this situation to me, I would just see someone who is stubborn and doesn't know how to work with business people.
In short, if you are going to take a strong stand against things that are otherwise legal, but you object to for reasons of morality, then you need to find someone to work for that has the same morals as you.
The right rules to play by
As a person who works closely with the CEO you need to learn to speak the language of business: money. That's all you need. The response you gave to your CEO is completely useless, and there is absolutely no way any argument along those lines is going to change your boss' mind. That can sound very mercantile, but it is simply the reality of business. A counter-example is the owner of the company I work for: he is a very reasonable person and not at all tight-fisted about money, but when I tell him we need to buy some tool or software package for our developers, his answer to me is always the same: "Give me a cost/benefit analysis" (not his exact words). From my perspective, that is the only right response. Even Google has a limited amount of money, and must pick and choose how to "spend" it.
The problem comes when a business owner is unable to see the long-term costs/benefits of short-term needs. The other answers here have already given you plenty of good examples of long-term costs that come with trying to do what your boss tries to do. Right now he only sees the short term "benefit" (it's not really a benefit): "I can make people write code for me for free!". He doesn't see the long-term cost. If that person isn't hired, how long will it take you (or someone else on your team) to figure out how it works? How much time will be spent fixing bugs since the person who wrote it isn't around? How do you deal with the fact that it doesn't properly work with the rest of your system since the person who wrote it knows nothing about your system? What about the very real loss that you will incur because your hiring process will absolutely drive away the best guys in your industry?
Your boss is only seeing the short-term benefit. For a person in your position, your job is to move past your own gut reactions and give an analysis of the situation that your boss can actually use to make decisions. If in the end your boss is incapable of seeing the bigger picture (or executing it) then that is a good sign that it is time to move on to a new job. If, however, you are incapable of properly communicating the big picture to your boss, that one is on you. What you have tried so far is definitely not going to get the job done.
And in the end, if you strongly object to the kinds of decisions your boss makes, that's also a sign that it is time to move onto a new job. Be upfront about the reasons you left your current job though, because it will be best for you to find a business that thinks the same as you.