It was a shocking turn of events for South Korea, which spent decades under military-authoritarian rule before it transitioned into a vibrant democracy and the world’s 10th-largest economy.