8 hours is a very long time, but it's very short if you want to go into NYC
First of all forget about the Statue of Liberty as it takes over 4hrs in itself.
Also remember that when you come back to the airport, you'll need to go through security again, and you'll need to be at the gate at least 30 to 45 minutes before take off (plane doors close 20 minutes prior to departure, and boarding starts 40 to 60 minutes before take off time.
to be on the safe side you'll need to allow at least 30 to 45 minutes to clear TSA and get to your boarding gate.
All in all you'll need to be back at the airport 90 minutes before your scheduled take off.
And with transportation time from NYC you'll need to start going back to the airport 2 hours (even 2h15mins) before take off time.
You'll have your carry ons with you, as there is no lockers in Newark. And you won't be able to do shopping (if it involves items that are prohibited on the plane) because your luggage are checked through to Edinmburgh and you won't collect them, so you won't be able to stow your purchases before clearing security
just consider what you're in for (and that you'll only have under 4 hours in new york) ... don't get lost in Central Park
Taking opportunity to go to NYC on a long (not that long actually) layover is tempting, but TBH, if you can have your flights changed and get a smaller connection, it will probably be a good thing. (just my $.02)