means that
being alone is preferable to associating with people whose influence or behaviour is harmful.
When her classmates began mocking another student, she decided to spend the afternoon on her own rather than join in. Better be alone than in bad company.