The animal companion needs to be able to enter melee combat and survive, maybe not as primary tank, but certainly the attention of a couple of adds. And the random fireball. And still not be dying, making the pet into an ability that only adds a weak link into the party; something the other players (not so) secretly wish wasn't present at all.
In short, the pet needs to soak as much punishment as any other character that doesn't actively avoid the heat of combat (because it can fire at a range or because it can fly/blink/invis et cetera).
Without that level of sturdiness, the pet is a ribbon ability and needs to be balanced as such.
Oh, and any animal companion that is actively worse than buying a frigging war dog before each adventure is like a slap in the face.
So the PHB AC is light-years away from acceptable. I don't remember out of hand, but it needs, at the very least
a) free will (no draining master's actions)
b) significantly better hit point progression (or AC) as it levels up. Can't remember if I thought it needed twice as many or even more, only that the PHB amount was hopelessly inadequate
c) magical attacks at level ~6 or so
Ideally, there should be Ranger spells to "share life" (master takes half damage inflicted to companion, and vice versa) and a specific Revivify Companion spell.
Again, it's "fine" to keep the current pet, but only if the Beastmaster subclass is entirely rebalanced to put essentially zero value on the ability. Actually, by far the easiest complete fix is to simply give everything the Beastmaster gets to the Hunter, and then basically pretend the Ranger class got only a single subclass...
Thank you for reading