Literally: by bad means or by good means; using unpleasant methods or pleasant methods.
2.
SpainLatin Americacolloquialinformalspoken
Figuratively: by force or by persuasion; the speaker will achieve a result either coercively or amicably, leaving the choice implicit or to the listener.
Examples:
ES: Podemos hacerlo por las malas o por las buenas. Usted elige. Pero va a venir con nosotros.
EN: We can do the hard way or the easy way but you're leaving with us.
ES: - Te pregunto si quieres que hagamos las cosas por las malas o por las buenas.
EN: I'm asking if you want to do this the easy way or the hard way.
ES: Lo podemos hacer por las malas o por las buenas.
EN: Okay? We can do it the hard way, or we can do it the easy way.
ES: Podemos hacer esto por las malas o por las buenas.