Trazodone is primarily prescribed for the treatment of major depressive disorder. It is also commonly used off-label to manage anxiety disorders, insomnia, and sometimes as a sedative for patients with other medical conditions.