Ayatollah Ali Khamenei ruled with an iron fist, shaping Iran's politics for nearly four decades and his death plunges the country into an uncertain future.