Is optimizing my database safe?

Yes; optimizing is perfectly normal and safe. WordPress Optimize does not use any trickery or undocumented dangerous processes.

WordPress Optimize uses database clean-up scripts with well-defined, common MySQL commands. Nevertheless, we always recommend backups, which cover every possibility; not just database malfunctions, but hackers, human errors, etc.