A historic building that was once a school will be transformed into flats after the council approved planning permission.