Let 0≤f∈C0,1(Rn). Given a domain Ω⊂Rn, we prove that any stable solution to the equation −Δu=f(u) in Ω satisfies a BMO interior regularity when n=10, and an Morrey Mpn,4+2/(pn−2) interior regularity when n≥11, where pn=n−2n−1−42(n−2n−1−2).This result is optimal as hinted by earlier results, and answers an open question raised by Cabré, Figalli, Ros-Oton and Serra. As an application, we show a sharp Liouville property: Any stable solution u∈C2(Rn) to −Δu=f(u) in Rn satisfying the growth condition, i.e.\ ∣u(x)∣=o(log∣x∣) as ∣x∣→+∞ when n=10; or ∣u(x)∣=o(∣x∣−2n+n−1+2) as x∣→+∞ when n≥11, must be a constant. This extends the well-known Liouville property for radial stable solutions obtained by Villegas.