Related to What did Rey tell Teedo that caused him to release BB-8? - Rey approaches Teedo and intimidated him as if he captured a sentient being. Are all droids afforded a status that gives them rights even when lost or away from their masters/owners?
TL;DR: Because he is sentient.
I will be using some quotes from the novelization of The Force Awakens, which describe BB-8 and his behavior, to support my case (because I happen to have it handy at the moment).
BB-8's dialogue (i.e., beeping) as a reflection of his emotions and sentience:
BB-8's beeps are variously described as:
"Agitated" when he spots the First Order ships approaching the village on Jakku
"Anxious" when Poe tells him to run away - he only does so, in the end, because:
Much to BB-8’ s regret, it could only protest a direct order, not reject it.
After Rey frees him from the Teedo, he faces the Teedo and beeps "loudly and challengingly" in its direction until Rey tells him to shut up
"Distinctly anxious" when Rey tells him to go away, after freeing him from the Teedo
"Laced with unmistakable desperation" when she repeats her request for him to leave
"Plaintive and anxious" when she tries to ditch him in town
When Plutt starts asking questions about him, BB-8 begins to "beep apprehensively"; when Rey shows interest in selling him, he starts "beeping furiously", because he had been paying attention to the conversation and "was not liking the turn it had taken, not at all".
Plutt scolds and demeans Rey, she stands up for herself, and BB-8 offers "a beep of admiration"
As they walk away from Plutt, BB-8 beeps "excitedly"
BB-8's behavior and thoughts as a reflection of his emotions and sentience:
His reactions to different situations are similarly varied, and highly suggestive of an advanced level of consciousness:
Even to a droid, Niima outpost was unimpressive... Nothing the droid saw was encouraging.
We even get a glimpse of how he feels about humans and other organic beings:
[Eating was a] biological process he understood from an objective point of view but for which he could never rouse much empathy.
And at one point he seeks out his own kind; he is well aware that he was a droid, and not a human:
Droids such as him were not meant for unpopulated places, and he desperately desired to find others like himself. Or, failing that, even people.
He himself is described as:
"Very, very concerned" when he sees the First Order ships approaching the village on Jakku
"In something approaching cybernetic panic" when he is rushing back to warn Poe; along the way, he encounters a flock of birdlike "bloggins", and although they peck at him, he deliberately avoids hitting them, dodging the flock members with "skill and patience", despite the fact that he finds them "annoying"
"Frightened" (several times, including when the Teedo tries to catch him)
"Insubordinate" when the Teedo tries to catch him
"Obstreperous" when he protests the idea of Rey selling him to Plutt; she gets annoyed and shuts him down:
Immediately, [BB-8's head] slid sideways until it made contact with the ground. No further beeps issued from its speaker. Artificial consciousness was absent now, and it was just a quiescent piece of machinery, a spherical piece of junk.
- When Rey is wandering through the Starkiller base, she comes across a utility droid, and freezes with terror, expecting to be caught. The droid ignores her and passes by, and she is grateful that "not all droids had the cerebral capacity of one like BB-8"
The scene with the Teedo:
The Teedo presumably didn't care about legal ownership of BB-8, and just wanted some money. Droids are generally treated as property in the galaxy far, far away, although the good guys treat them like sentient property. They may not have full rights, and I assume a droid's owner can do whatever he or she wants with it, but the heroes generally try to strike a balance between taking a droid's feelings into consideration while also making use of the droid.
Rey seemed to be acting out of compassion, perhaps because she herself is often treated badly; she also deemed the Teedo's behavior as "particularly impolite", and said he "wanted [BB-8] for parts". She may have assumed that BB-8 was on an errand for his owner, and that the Teedo was breaking some sort of unspoken code of scavenging.
She didn't like it - him. Her fondness for most machinery extended to its trade equivalent in food. But she found herself feeling sorry for this small, helpless droid. At least, she told herself, this one seemed harmless enough.
I assume that, had the Teedo stolen BB-8 and scrapped him for parts, he would be guilty of theft, destruction of property, etc, but not murder.
As should be clear by now, BB-8 is definitely self aware, and possesses sentience/consciousness, albeit "artificial consciousness". He fears for his well-being and the well-being of his friends, he gets annoyed, he is insubordinate, he gets frustrated, he experiences sadness, loyalty, comradeship, happiness, and doubt.
He doesn't feel these emotions and impulses in a vacuum, of course - he acts in accordance to them, and makes decisions based on them. For example, when he sees Finn wearing a jacket that belongs to his master Poe, he alerts Rey to the apparent theft (despite the fact that Rey has no real reason to care, from a perspective of pure self-interest), and after she knocks Finn down, BB-8 makes it abundantly clear that he is enraged by Finn's apparent thievery, and repeatedly shocks him with a Taser. When Finn explains that he came to Jakku with Poe, but believed the latter to be dead, BB-8 reacts appropriately, immediately foregoing his rage and sinking into grief and despair.
He is more limited in his actions than we are: He apparently can't reject a direct order, no matter how much he wants to do so, but can only protest it. His programming inhibits him in less direct ways as well - at one point, he follows Rey, staying "as close to her as protocol allowed". This suggests that he is programmed with a complex set of guidelines, presumably designed to accommodate basic etiquette, including, perhaps, some respect for "personal space".
More to the point of the question - which focuses on sentience - he knows he is a droid, and wants to be among his own kind, but sees humans as an acceptable substitute - even if he can't "rouse much empathy" for the human need to eat, despite understanding it in an objective sense.
Regardless of the mechanical and artificial source of his sentience, he clearly possesses a wide range of emotions, fears, hopes, desires, and opinions, and these are quite similar to their analogues in humans and other intelligent species. This isn't mere parroting of what he sees, it is intuitive, natural, and authentic. He doesn't just appear to be a thinking, feeling, self-aware entity; he truly does think, feel, and possess a robust awareness of himself.
Although BB-8 would presumably have to obey Poe even if he didn't like him, this clearly isn't the case - BB-8 is not only obedient, but loyal and affectionate. He obviously cares for Poe, and later, Rey and Finn, quite deeply. I don't see any evidence that his affection for his organic companions is substantially different from their affection for one another. And although I haven't touched on it elsewhere in this answer, it is self-evident, in my opinion, that the same is true of R2-D2. The most prominent droids in Star Wars are quite plainly sentient, emotional beings who love their companions and display a full range of emotions throughout the series.
Thus, many droids, including BB-8, obviously do possess sentience, self-awareness, emotions, and personalities, and although some aspects of their behavior are regulated by programming and fairly rigid protocol, these limitations and prohibitions seem to be a very minor part of the overall picture. The vast majority of a droid's actions are motivated by internal decision making processes, emotions, and values, in a manner that appears to be almost indistinguishable from our own decision making processes, emotions, and values.
As someone who's quite literally on the bottom rung of society (doing work that's almost too low value to waste a droid on) Rey sees BB-8 as a kindred spirit.
But the small droid was putting up such a spirited defense that its capture seemed unjust. This unit wasn’t the average binary loadlifter or probot spy. Its yelps were frantic pleas for aid, and Rey had a feeling the droid would try to assist her if their positions were reversed and she were caught in the net.
To grab the Teedo’s attention, Rey shouted in his native language. Both captor and captive paused in their struggle and looked up at her. She continued shouting, ordering the Teedo to leave the droid alone. The reptilian Teedo hissed through his rusted mask. - Star Wars: The Force Awakens - Junior Novelisation