Since animals are an analogue of humanity, we observe duties to mankind when we observe them as analogues to this, and thus cultivate our duties to humanity. If a dog, for example, has served his master long and faithfully, that is an analogue of merit; hence I must reward it, and once the dog can serve no longer, must look after him to the end, for I thereby cultivate my duty to humanity, as I am called upon to do; so if the acts of animals arise out of the same principium from which human actions spring, and the animal actions are analogues of this, we have duties to animals, in that we thereby promote the cause of humanity. So if a man has his dog shot, because it can no longer earn a living for him, he is by no means in breach of any duty to the dog, since the latter is incapable of judgment, but he thereby damages the kindly and humane qualities in himself, which he ought to exercise in virtue of his duties to mankind.[Kant, Lectures on Ethics, Heath & Schneewind, eds. Heath, tr. Cambridge University Press (Cambridge: 2001), p. 210 (27:459).]
Kant gets a lot of criticism for this argument these days, because he reduces our moral obligations to animals to our moral obligations to human beings, but I think Kant's argument here is a case of Kant excelling himself. I think he is right about a number of very important things.
(1) If you look at how we come to treat animals as morally important, I think there is good reason to think that Kant is right about the psychology: the analogy matters, psychologically, and is a considerable part of why people come to the view that they have obligations to nonhuman animals. Taking loyalty as being morally valuable in human beings, we can't easily bring ourselves to treat something like it in animals as worthless; and if we do treat the loyalty of animals as morally unimportant, that immediately raises the question of how morally important we could really be taking it to be even in the human case.
(2) More than the psychology, I think Kant is onto something very important about moral reasoning. Kant is known for holding that the only thing that is morally important is doing your duty; but people tend to forget his recognitions, as here, that doing your duty requires more than the bare duty itself -- if you have a duty to do something, you have some kind of a duty to do what prepares you to do your duty, you have some kind of duty to do what makes it easier for you to do your duty, etc. Every strict moral obligation has an aura of secondary obligations, and ignoring the latter will often get you the wrong moral answer when we are asking what your obligations are. This is especially true since we are not abstract reasoners but rational animals, trying to be moral while living an animal life in an animal world. If anything, I think Kant's failure here is not to recognize that these kinds of analogies are actually very pervasive throughout our moral lives.
(3) Kant is also right, I think, that the case of nonhuman animals is one where you cannot ignore the extraordinary moral importance of character, even if, like Kant, you do not take morality to be based on character. Deliberately to do things that 'damage the kindly and humane qualities' in you is not a some quibbling moral matter; it is a very serious one, regardless of what you take the foundations of morality to be. And our relationship with nonhuman animals in particular is a personal interaction, and our moral character is directly of relevance to everything in it. When you interact with a dog, you are doing so as a person, and you are using the same skills and habits that you develop for interacting with other human beings. That you are interacting with something that is not human does not relieve you of the responsibility to act like a human person capable of interacting humanely on a personal level with other human people; that's still there in the background. And the kind of person you are, and your ability to interact with other people, is a matter of character.