Shango is remembered as the third alafin of Oyo, an actual ruler of an actual state in what is now southwestern Nigeria. The traditions say he was a powerful and violent king with an interest in charms, that he accidentally called down lightning on his own palace and killed members of his household, and that he left the city and hanged himself, after which his followers proclaimed that he had not died but had ascended, and that the lightning strikes which followed proved it. Oba ko so, the king did not hang, became his praise cry and the title of a celebrated Yoruba opera.
How much of that is history is not recoverable. Oyo's dynastic lists are oral and were written down late, and there is no way to put a date on the reign. What matters for understanding Yoruba religion is that the tradition holds both accounts at once without strain: Shango is the elemental power of thunder and he is a named king with a genealogy. Several orishas work this way, and it makes the Yoruba pantheon quite unlike the Greek one, where the gods are categorically not former people.
The political consequence was substantial. As Oyo expanded across Yorubaland in the seventeenth and eighteenth centuries, Shango's cult expanded with it, and his priesthood served the empire's interests. Lightning was read as royal judgement: a house struck by lightning was understood to have been struck for cause, and Shango's priests held the right to enter it, collect the wreckage and levy a fine before the family could rebuild. A god of thunder who is also a dead king is a god whose priests can tax a storm.