Iran’s president on a rare visit to Africa has sharply criticized Western nations’ support for homosexuality as “one of the dirtiest things which have been done in human history.”