Is writing a book for someone illegal?

Is writing a book for someone illegal?

Writing something for someone else and getting paid for it is a standard practice in many industries, and it is considered genuine freelance work and not illegal.