Is it illegal to destroy other planets?

There are no specific laws regarding the destruction of planets. There is the United Nations' Outer Space Treaty, which claims space as the province of all mankind, and not subject to claims by any one nation. Technically, this treaty might suggest that attacking a planet would be an assault on all mankind, but who is going to enforce the claim against somebody who can destroy a planet?

There are, however, treaties concerning the placement of weapons of mass destruction in space. The Outer Space Treaty and the SALT II treaties prohibit placing WMD's on space platforms. They do, however, permit the use of conventional weapons and Kinetic Energy Weapons (KEW's).

A KEW is basically a rock or projectile without a warhead dropped from high orbit that relies on gravity to accelerate it to extremely high speeds, giving them enough energy on impact to explode with the force of a nuclear weapon. A sufficiently large KEW could destroy a planet without much trouble. In fact, it would be a lot cheaper and easier than lofting enough nukes to do the job.