The undisputed head of post-revolutionary Iran nurtured the country’s global ambitions but faced criticism at home over a withering economy.