Making Pokemon ROM hacks for personal enjoyment is generally not illegal, but selling them is. Distributing a free patch is usually safer than selling a modified cartridge.