Throughout the world, computer programs are protected by copyright law. Copyright protects the expression of an idea in the form of a program, hence protecting the developer's (or company's) investment in writing the software. Copyright law provides a bundle of exclusive rights to the software developer; among others, the right to reproduce and make adaptations to the developed computer program. It is a breach of these rights to make reproductions or adaptations without permission of the copyright holder. Further, license agreements may also bind the user to operate the program in a certain way and to avoid using decompilation or disassembly techniques on that program.

Different countries have different exceptions to the copyright owner's rights or precedent has been established in court proceedings. This means that these uses are allowed by law. The most common ones are:

Decompilation/disassembly for the purposes of interoperability (to another piece of software or hardware) where the interface specification has not been made available,

Decompilation/disassembly for the purposes of error correction where the owner of the copyright is not available to make the correction, and

To determine parts of the program that are not protected by copyright (e.g. algorithms), without breach of other forms of protection (e.g. patents or trade secrets).

Not all countries implement the same laws, you should contact your lawyer if in doubt.

But just as gun owners who defend the legal use of guns are not endorsing cop killers, or free speech activists who attack overly broad restrictions on pornography are not thereby promoting the spread of child pornography, so too is the defense of p2p technologies not an endorsement of “piracy.”

It could be added "so too is the research of decompilation technology not an endorsement of
the violation of copyright".

Innovation

In Bonito Boats, Inc. v. Thunder Craft Boats, Inc. 489 U.S. 141(1989), the U.S. Supreme Court
regarded reverse engineering as "an essential part of innovation", likely to yield variations
on the product that "could lead to significant advances in technology". (From "Reverse Engineering Under Siege",
Pamela Samuelson, Comm. ACM 45(10) October 2002.) It is possible that decompilation
(when it becomes practical) could do the same for software that physical reverse engineering
does for boats and other fields of endeavour.

The article above also states that "Courts in the U.S. have also treated reverse engineering as
an important factor in maintaining the balance in intellectual property law". It goes on to point
out that patents confer significant advantages to their owners, but only in return for disclosure
of the invention, so that the public will ultimately benefit from the it. Perhaps decompilation
can help redress the balance that the recent flood of dubious software patents has perturbed.

The U.S. DMCA

With the Digital Millennium Copyright Act (DMCA), the USA has become one of the worst countries
as far as the freedoms of computer users is concerned (e.g. see
the Anti-DMCA Website, and
CEM Kaner's Blog;
point 8 refers to reverse engineering including decompilation.).
As Cem points out, California courts have started enforcing no-reverse-engineering
(link).
Worse, the US government attempts to apply pressure through its economic might to other countries.
The European Union has bowed to this pressure, while Australia seems to have so far resisted the worst of it.

Despite all this, it appears that decompilation in the USA is still legal under certain circumstances. The DMCA has been interpreted as follows on this page, even where the circumvention of a "copy protection device" is involved:

“The exception allows reverse engineering of computer programs if the reverse engineer lawfully obtains the program, seeks permission from the copyright owner, only uses the results of their efforts to create an interoperable computer program and does not publish the results".

MGM v Grokster

In June 2005, the US Supreme Court ruled:

"We hold that one who distributes a device with the object of promoting its use to infringe copyright, as shown by clear expression or other affirmative steps taken to foster infringement, is liable for the resulting acts of infringement by third parties using the device, regardless of the device's lawful uses." (545 U.S. (2005)).

This appears to overturn certainty that came from the landmark Sony Betamax case (464 U.S. 417 (1984)), which said in effect that manufacturers of potentially infringing devices (such as VCRs) are not responsible for the illegal actions of users, as long as there are "substantial non-infringing uses" for the device. Now, there is a question of inducement.