To answer the question, let's first define a few terms.
Morality is defined as the universal rules that moral agents should live by.
Moral agent is defined as any entity that is capable of modifying its behaviour to match an ideal standard (i.e. a moral rule).
Therefore, any entity that cannot and will never be able to learn an ideal standard, and that does not have the cognitive ability to modify its behaviour to match that standard, is not a moral agent. Morality does not apply to entities that are not moral agents.
If you accept the definitions provided so far, let's explore the implications:
1) Inanimate objects - rocks, water, air, photons of light - these are obviously not moral agents. You cannot hold the air morally responsible for the tornado it caused.
2) Plants - Plants have the capacity to modify their behaviour to match ONE specific goal, which is to survive and reproduce. Plants cannot learn other goals or ideal standards, therefore, they are not moral agents. You are not guilty of murder for killing and consuming a plant.
3) Insects - The analysis for plants also applies to insects.
4) Animals - Certain animals have the capacity to learn ideal standards (i.e. rules). You can teach a dog not to harm people. You can teach a dog not to steal. You can teach a dog to behave. If a dog has the capacity to learn and obey rules, it is a moral agent. Morality applies. If the dog does not harm you, you may not harm the dog.
**Edit: a reader has identified a logical error I made in my analsysis of the dog. Moral agency is the ability to modify behaviours to match an ideal standard. The dog cannot hold an ideal standard in its mind (unless otherwise proven by science). Therefore, it is not modifying its own behaviour. Its behaviour is being modified by an external agent - a human being- through classical conditioning.
An alligator, on the other hand, cannot be trained to follow moral rules. If its instints tells it to bite off your arm, it will bite off your arm. Alligators are not moral agents. It is not immoral to shoot an alligator on sight as long as nobody owns it.
Now let's reconsider the dog. Yes, it has the capacity to learn certain rules. However, it takes tremendous effort to train it to that level. In the absence of training, a dog will not obey rules and is a potential threat. In this case, it is not yet a moral agent, but it has the potential to be a moral agent.
It is not immoral to restrict the freedom of entities that are potentially moral agents but have not yet reached that level. Thus, untrained dogs may be confined to a specific space. The same may be done to human babies and toddlers. The same reasoning applies to why human children are not allowed to drive cars or handle guns without adult supervision. In short, the degree to which potential moral agents are unable to reciprocate moral rules is the degree to which moral agents may restrict their freedoms.
Let us use what we've learnt above to explore the following moral questions:
Is it immoral to hunt animals if certain animals are potential moral agents?
First, moral agents are morally justified in using force to defend themselves against those who initiate violence against them. If a lion comes at you, you may shoot it dead. However, is it moral for you to hunt lions?
Do lions have the potential to become moral agents? To a certain degree, yes. Lions may be trained from birth to respect moral rules (i.e. do not maim or kill other living creatures). However, an adult lion born and raised in the wild can never be trained to respect moral rules. In this situation, the adult lion is not a potential moral agent. It is simply a non-moral agent. Hunting an adult wild lion is not immoral (unless it is somebody else's property). Hunting a domesticated lion that has been unleashed into a sanctuary is immoral because this lion will respect moral rules.
Is it immoral to raise animals in captivity, thereby depriving them of their ability to reach their potential as moral agents?
A cow raised in captivity is not a moral agent. It has not learnt any moral rules. It will not obey moral rules. Slaughtering and consuming a cow in this case is not immoral. However, the reason why it is not a moral agent is because it has been denied the chance to reach its potential. If a psychopathic cannibal confined a human baby to an enclosed space and denied the baby the chance to become a moral agent, does that mean it's alright for him to eat that baby?
Your gut feeling is telling you that this scenario is downright evil. But feelings do not matter. Only logic matters, so let's explore the logic.
Morally speaking, what is the difference between a human baby and a newborn calf? Both have the potential to learn moral rules. However, the human baby will learn the rules much faster and will have a deeper understanding of the rules. The calf's ability to do the same is much more limited, but not impossible. Therefore, is it fair to say that a farmer has deprived the calf of its ability to become a moral agent when the probability of success is low? A psychopathic cannibal who raises a human baby for consumption has definitely deprived the baby of its ability to become a moral agent. With the cattle-farmer, it is not so certain.
A human raised in the absence of training and education will, in his natural state, develop moral rules. We know this because our species did not begin with moral rules, yet we have developed rules over time. Can other animals do the same? Only science can give us the answer to this question.
If the science fails to produce evidence that animals, in their natural state, can develop moral rules, then it is not immoral for humans to raise these animals in captivity for the purpose of consumption. These animals will not become moral agents in the absence of human intervention. Therefore, if these animals do not become moral agents, it is not because we have deprived them of anything. They don't have 'it' to begin with unless we give 'it' to them. We are not morally obligated to give these animals anything.
If the science demonstrates that animals, in their natural state, are capable of moral reasoning and develop moral rules over time, then it is absolutely immoral for humans to deprive these animals of the chance to become moral agents. In this case, we have taken something away from them that they would have acquired in their natural state.
Whatever your feelings about these moral questions, set them aside. Let reason, logic and evidence guide you to the conclusions.