Laws like these are generally called "Son of Sam" laws and are named after serial killer David Berkowitz, who went by the alias "Son of Sam" while taunting the police about his crimes. On arrest, many feared Berkowitz would try to get a book deal to sell the story of his crime spree as told by him and New York State quickly passed the first "Son of Sam" law in the nation.
Son of Sam laws target notorious criminals who have become infamous from the press attention they offer. Under U.S. law, you are not allowed to profit from crimes. But most laws were written to seize money and items used to generate illegal profits. No one had anticipated a criminal of notoriety writing a book, or selling movie rights, or giving exclusive interviews after arrest and conviction.
It's also important to note that Son of Sam laws are not universal. Some states have them and others do not. In so far as I'm aware, writing a book about your crime in Nevada for profit is still legal (Though last word I had is early-mid 2000s).