The fact that wizards and witches have souls is fundamental to the Harry Potter series as a whole; in fact, the story hinges on this fact, since Harry's primary task is destroy all of Voldemort's Horcruxes, that is the preserved pieces of his damaged soul, in order to ultimately defeat him. However, the issue of who or what, aside from wizards and witches, has a soul is a fairly open one.
The ghosts in Harry Potter raise some interesting questions about the nature of the soul. In the wake of Sirius's death, Harry seeks out Nearly Headless Nick in the hopes that somehow the sympathetic ghost could help him understand what happens when someone dies. In the course of this conversation, a number of salient points emerge. Nick tells Harry: "Not everyone can come back as a ghost... only wizards." Since Nick has chosen to "leave an imprint of [himself] on earth, to walk palely where [his] living [self] once trod," all that he can tell Harry is that those who have died have "gone on."
If only wizards and witches can become ghosts, what are the implications for other sentient beings, magical or otherwise? Apparently, Muggles cannot become ghosts (good news for Harry, who might otherwise have to worry about a malevolent, if transparent, Uncle Vernon haunting his future). What about Squibs? Is magical ability a requirement to become a ghost? In that case, could house elves, centaurs, and goblins - all powerfully magical beings - become ghosts? What about giants, who do not appear to be able to perform magic, but are part of the magical world and are certainly sentient? What about animals, some of which, like acromantulas, can talk and have fully developed personalities, moral systems, and political loyalties?
One thing that makes me a little uncomfortable with the logic surrounding ghosts in Harry Potter is that it indicates that wizards are given an active choice at death that is denied, at the very least, all Muggles. The bigoted elitism of Voldermort's Death Eaters, represented in the statue "Magic Is Might" in which a wizard stands upon the miserable bodies of Muggles, is really just the nasty incarnation of an idea that permeates the whole Wizarding world. The wizard most sympathetic to Muggles, Mr. Weasley, sees them almost as children, admiring their "ingenious" inventions and regarding them with an indulgent fondness. This paternalistic attitude is somewhat validated by the fact that Muggles are in fact severely limited in Rowling's universe. The fact that Muggles cannot choose to become ghosts could indicate one of two things: 1) it could support the fact that magical ability is a requirement to become a ghost, or 2) it could indicate that Muggles have less agency upon their death and therefore are never granted a choice. The humanitarian view of Muggles is not unlike our humanitarian view of such intelligent animals as elephants, primates, and whales, their lack of magical ability paralleling animals' lack of speech.
The reason that I am so concerned with who and what can become a ghost is this: typically, ghosts are defined as a the corporeal form of a soul. If only wizards and witches can become ghosts and ghosts are in fact souls, it is rather problematic that Muggles cannot become ghosts. We know, however, from the books that Muggles do have souls because Dementors happily prey on wizards and Muggles alike, as we see in the
fifth book, when Harry and Dudley are attacked. Thus, we know that, at
least to a Dementor, the soul of a wizard and the soul of a Muggle are
essentially the same. Since Squibs are essentially Muggles that had the misfortune of being born into a Wizarding family, they evidently also have souls as well, though their ability to become a ghost is questionable.
Non-human intelligent creatures pose other problems. House elves, goblins, and centaurs are as intelligent as human beings and while their magic, like that of wizards, must operate within certain bounds, one of the central lessons of the series is they are not lesser, but different, than their human magical peers. My assumption, particularly considering the character of Dobby, is that they also have souls.
The question becomes trickier as we turn to giants. Although giants have primitive linguistic ability and a set of social protocols, their level of intelligence is questionable, but intelligence and the soul are two entirely separate things. It seems reasonable to me to think that giants have souls, for the following reasons: 1) they are capable of interbreeding (how in heaven's name, I don't, and don't really want to, know) with human beings and their offspring - Hagrid and Madame Maxime being the examples - have magical abilities, 2) Grawp, Hagrid's half-brother, is able to develop bonds and loyalties, and even compassion, that are outside the assumed bounds of his giant nature. It's difficult to believe that a being with a soul and a being without could procreate together and it is clear that giant nature, bestial as it is, is capable of the development of those deeper emotional bonds with which the soul in Harry Potter is concerned; therefore, giants also have souls.
Far trickier is the case of animals. Magical animals in the series exist in several classes. There are those that can speak and exhibit intelligence equal to their human masters, like Aragog the acromantula. Perhaps, acromantulas belong among house elves, goblins, and centaurs, but I think there is a distinction. Whereas house elves, goblins, and centaurs have highly complex social structures, belief systems, and political perspectives, acromantulas seem to be bound to instinct in ways that the former are not. For instance, Aragog forbids his offspring from preying on Hagrid, but feels no remorse for allowing them to attempt to eat Harry, Ron, and Fang - three of the beings that Hagrid loves most in the world. Hagrid would almost certainly believe that Aragog, a beloved pet, has a soul, but I think this case remains an open question.
Then there are the many magical animals that act largely like regular animals. When Ron takes his rat to the Magical Menagerie for veterinary care, the witch who works there asks him, "What powers does he have?" Thus we know explicitly that, as in the case of humans, there are animals with magical abilities and those without. Hedwig is able to deliver mail without an address, Crookshanks can detect that Scabbers is not what he seems, and Fawkes can be called to protect those who are loyal to Dumbledore. Some animals, like owls, seem to share traits common to their species, while others, like cats, seem to have more individually defined powers. Emotionally, I want to believe that these beloved pets do have souls, but it's a tough call, not least of all because having a soul in Harry Potter carries with it a deep responsibility to not harm the integrity of that soul. Another issue is that animals can be conjured from or transfigured into inanimate objects. For instance, Fudge transfigures the Muggle prime minister's tea cup into a gerbil. This is not a temporary bit of magic, as the gerbil becomes the P.M.'s niece's pet. It seems entirely impossible within the framework of the story that a soul could be conjured from nothing and therefore the ability to practice magic in this fashion would seem to contradict the possibility that animals have souls. So, it is possible that animals have souls, but it seems more probable that magical animals are more likely to have them than ordinary, non-magical animals.
What about Peeves, another problematic case? Peeves is a poltergeist or a spirit of chaos, classed, like Dementors and boggarts, as a non-being. Presumably non-beings do not have souls, but in the case of Peeves, I wonder if they could. Peeves has emotional responses, such as fear of the Bloody Baron and respect towards the Weasley twins, that might indicate a somewhat more complicated nature. While Dementors and boggarts show not the slightest shred of humanity, acting always by their natures as a species, Peeves shows a certain degree of agency and decision-making that makes me doubt, just a bit, whether he may not be a creature with a soul.
The finer points of these issues can, obviously, be contested, though J. K. Rowling has resolved many issues through the years and may yet have something to say on this one. Meanwhile, it's fascinating to contemplate the implications of these metaphysical questions in the Harry Potter universe.