Indeed, in the most general sense (and probably more so in democracies) laws represent the codification of what society as a whole deems acceptable and what should happen when someone breaches that code.
Of the people in power, not the people. Most certainly the people who were enslaved didn't believe it was moral or ok. Similarly for women's rights, LGBTQ+, etc etc. So again, laws and morality are different things and should be treated as such.
Assuming a government that reflects the people like democracy, which is I assume the context of this discussion. And to be clear they are different, but they are very closely related. And the relationship is that law follows and encodes the people's morality. Usually by majority depending on the form of government.
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.
Democracy is not where a government reflects the views of the people. Otherwise the democracies of the world would not have taxes or ubiquitous surveillance or perpetual war. Nobody anywhere wants these things.
I would disagree with that; I want taxes because I get something out of taxes. Taxes are me paying the government for certain services they provide me, like I'm hiring a contractor.
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.