The Mahabharata says many things about the relationship between violence and morality, some of them contradictory or seemingly contradictory, because it speaks with many different voices (in debate) and to many different social groups. Those looking to find—or worse yet (from a Hindu standpoint), impose—one unified doctrine on the many philosophies, voices, and castes that the debate involves are missing the whole point of the text.
The Dharma (way of righteous conduct) for a Brahman (moral/spiritual leader) for whom Ahimsa (non-violence) might be appropriate would be immoral for a Kshatriya, whose Dharma as a ruler/warrior is to defend the defenseless, which requires him to fight. Each group in society has different responsibilities and duties (Dharma), and these have different ramifications (Karma).
The epic distinguishes between gratuitous and uncivilized violence, which is condemned, the violence necessary for punishment (danda), and the warrior's violence (ugratva) against enemies that is the duty (Dharma) required of the Kshatriya for the maintenance of society.
When Prince Arjuna (a Kshatriya) questions the morality of war, it is the god Krishna himself that corrects him and lays out the arguments for necessary violence in this case and urges Arjuna to fight. It is a war of Dharma because his enemies, the Kauravas, had broken the laws, and so Arjuna would have to fulfill his Karma to uphold Dharma (righteous order).
He resists, because it goes against his desires, which he is urged to let go of. Everything is an illusion (maya) belonging to the divine. He would only be killing the mortal bodies of those who would continue the cycle of life. The killing of the body would not affect the reincarnation (Moksha) of their souls. Arjuna realizes the war is not about him, but about fulfilling Dharma itself. Arjuna fights because it is the moral thing for a Kshatriya to do.
Is the text arguing that violence is justifiable under certain circumstances, or does it suggest that violence always has negative consequences? It argues that violence is justifiable (and a duty), but only for certain people in certain circumstances. As far as violence always having negative consequences, the Mahabharata speaks in many voices to many different people whose Karma and Dharma will not be the same. Some of the voices, particularly later in the text, suggest that violence always has negative consequences. Others disagree. For example, for Arjuna not to do his Karma to uphold Dharma would have had negative consequences for him, according to Krishna. Although modern Western-influenced interpreters like Mahatma Gandhi have made the argument that the text is anti-violence in total, that argument runs counter to Hindu tradition and the plain meaning of the text.