Application of The Ethical Code
Abiding by some code of ethics is more expensive than ignoring it. The ACM code tells us to "Honor property rights including copyrights and patent": obviously, it's cheaper to steal someone else's copyrighted work than to build an equivalent work. Examples could be found for the other moral imperatives in the code.
Legal systems work, broadly speaking, by introducing a cost of non-compliance so that rational actors should also be abiding actors. This is an example of removing an externality, discussed in Chapter 15, Philosophy, of this book. If stealing the copyrighted work is going to cost the thief in legal fees, damages, and lost reputation, the other route becomes attractive.
For most of us making software, the legal framework we operate in doesn't directly apply to our actions. Laws exist covering data protection, and certain fields are strongly regulated (principally, life-critical systems such as control software for medical devices...