Laws in theory encode the morality of the people. The people who believed it was moral to own humans encoded their morality into their legal system.
If many people feel like the laws do not represent their morality, that's generally a problem, and will result in either change in the laws, or change in government altogether. They are quite intrinsically linked.
As for surveillance/war, although they have been supported by large chunks of the population in the past, I would say democracy aims to reflect the views of the majority. But it's also not magic, it's a fixed system -- a complicated system, but just a system. You vote for the person/party that best reflects your views. It seems quite a bit more likely to be a reflection of the people than other forms of government where the people tend to have less of a say, but not necessarily of course.