Yes, you’re allowed to leave the airport.
The US doesn’t have a true “transit zone” like some other countries. Everyone entering the US, even on a connection, has to clear immigration and customs first. Since you have ESTA and are legally admitted, you’re free to leave the airport during your layover.
A few things to keep in mind:
You’ll clear immigration, pick up bags, clear customs, then re-check for your next flight
On the way back to the airport, you’ll go through normal security again
Make sure you’re back with plenty of time, especially if it’s a busy airport
Plenty of people leave the airport on long US layovers like this. As long as your ESTA is valid and you’re admissible, there’s no requirement to stay airside.
Enjoy the mini stopover.