The thing is that we all live in a society, not the state of nature. A society that is more or less founded on Social Contract Theory. The idea of that being that we all agree to give up certain rights, namely the right to do whatever we want (license - note that we basically agree to give up the right to do things that harm others. Essentially, liberty turns into license at another persons' face) in exchange for the protections that society offers. In this instance, there is a very real threat to others from refusing to follow social distancing and/or wear face coverings. This also happens to be the literal foundation of the U.S. Constitution. So, the government, certainly the States, have legal and moral authority to tell people to stay home or to choose to let them leave the house but only if they follow certain rules like wearing face coverings in public.