Yes, you can leave the airport during a layover, provided your passport allows you visa-free entry to the country you're in, and you have enough time between flights. In fact, some people intentionally book flights with longer layovers (which are often cheaper) so they get to see a new city.