The justifiication is generally:

We can recognize that animals are conscious. Very rarely do animals consciously want to die, and very demonstrably the way most humans prepare and kill animals for consumption is observably harmful to them - they experience pain and suffering throughout the process.

I don't think we have laws against harming each other exclusively because we operate at a mental capacity to talk about those laws. Because its still illegal to kill a human being operating at a mental state reduced below that of most of the animals we eat due to disease or impairment. We constructed the social contract to not harm each other both out of the selfish desire to not be harmed ourselves and out of the empathy to project that if we do not want to be harmed or killed most other people would also probably not want to be either, and we could agree to prohibit that.

It is a definite leap to extend such courtesy to animals, because they generally don't have intent or goal. Animals are great at conveying their desire not to be harmed and to avoid known sources of harm - electric fences, getting a door slammed on their tail, etc. Some can even mourn death as seen in dogs, elephants and dolphins.

Its not that great a leap then to presume that most animals don't want to die, even if they cannot understand the concept in much the same way that young children under 8 generally aren't treated as inhuman just because they have yet to comprehend the concept of death. Hell, humans don't even achieve object permanence until they are upwards of 3-4 years old some times but again you don't have different laws depending on intellectual capacity on whether it is allowed to hurt or kill someone.

We base all those rules and laws on the presumption that other people are conscious, regardless of their intellectual capacity to express or comprehend said consciousness, and that the rules we can agree upon between ourselves that we don't want to be harmed and thus we prohibit causing harm to one another should also apply to those who cannot express such desire as long as they are still human.

We also have ample law about animal cruelty and abuse, again enshrining the recognition of consciousness in other species.

If we can recognize animals as conscious, recognize their propensity to have wants and desires, recognize their desire to not be harmed and to be ill affected by harm, and even in some cases their desire to express mourning and loss in death than the only reason you wouldn't apply the same rules we use between ourselves to prevent harm to them is wholly arbitrary - it isn't on an intellectual basis, and it isn't on a perceptive basis, it would be purely human exceptionalism for no greater reason than "I am human, screw everything that isn't". But that wouldn't be consistent in law unless animal cruelty was considered acceptable universally, so its presently a strong contradiction in most societies.

If you demonstrably don't need to eat animals to survive, you recognize their consciousness, and you extend personal protections you want for yourself to others because you can empathize with them, then it comes down the same mechanism that can help abate racism or sexism in society - exposure to the maledicted class is often very effective in informing people on the empathic response they should be having to most sapient biological life. Consult /r/happycowgifs for more info.