Of course, it might not be prudent to do so - they could do a bad job or alienate your neighbours - but that’s a different thing. Or it might be that something is cheap because of an unpriced negative externality. Or someone might be desperate for a job because they are the victims of immorality or injustice in other ways, but that is a separate, though important, question.
Ceteris paribus, though, in many cases the cheapest decision can easily be a moral one.
This raises a paradox. Many people would think that an economic system which allows workers to be exploited is immoral. But given that this system exists, it might be morally justifiable for a firm to hire the individual worker it can exploit the most, as s/he most wants the job.
This paradox might justify Marx’s argument - that the problem is not that individual capitalists are immoral, but rather that the system itself is faulty.