Hume's position regarding the perennial free will vs. determinism debate evolved over the course of his philosophical career. In the early part of that career, he treated the whole issue with some disdain, seeing it as little more than a pointless verbal dispute.
Nevertheless, Hume's disdain did not prevent him from weighing in on the debate. In his A Treatise of Human Nature, he appears to come down firmly on the side of the doctrine of necessity as against the doctrine of liberty, which he dismisses as a “fantastical system.” Not only that, he argues that it is “absurd” and “unintelligible.”
Yet later on, Hume would modify his opinions somewhat, eventually coming to adopt what is called a compatibilist position. In other words, he came to believe that, far from being diametrically opposed, as was traditionally thought, liberty and necessity were in some way compatible.
To a large extent, Hume's change of heart can be traced to his theory of causation. The main point of this theory is that what we normally think of as a causal link between objects is actually nothing more than a constant conjunction.
So, for instance, if I see one billiard ball striking another, I'm not actually witnessing causation at work; one ball does not cause the other one to move. All that I can faithfully observe is the constant conjunction of two separate objects. We only apply the term causation to such a phenomenon because our minds have been habituated by custom to do so.
As causation on Hume's account is problematic, so too is necessity, of which causation is an essential component. Even so, the notion of necessity, like the traditional concept of causation, is still very useful, and we cannot do without it. In practical terms, if we abandoned the notion of necessity completely, then there would be no regularity and therefore no moral laws. The consequences for society would be very grave indeed.
At the same time, if we are to have moral laws, then we are also required to accept some measure of liberty in human conduct. As part of his compatibilist argument, Hume holds that liberty, contrary to what many philosophers have believed, is not incompatible with necessity but only with constraint, which is not quite the same thing.
As with his position on necessity, Hume's standpoint with regards to liberty is based on a consideration as to what is essential for a stable, well-ordered society. If we do not assume at least some liberty in human actions, then in practical terms it becomes difficult to see how people can be held morally accountable for their actions.
Whatever its drawbacks as a philosophical theory, then, compatibilism as Hume understands it is essential for any society worthy of the name and any workable system of human morality.