Optimal and Stable Multi-Layer Object Rearrangement on a Tabletop