As part of the Government's policy of devolving power to the regions, they proposed that London should be controlled by a Greater London Authority. It was also felt that the authority should be led by a full time executive officer who (unlike town mayors or CEOs) should be elected directly by the people. Those proposal were put to a referendum in 1998, with 72% of voters in favour of the proposal.
So the reason that London has an elected mayor is because the people of London voted for the proposal (as part of a package setting up the GLA) in a referendum.
Having a mayor who is elected separately to the authority gives the people power to separate personalities from party politics, in the same way that the USA does. For example, the USA can have a Democrat-led government but with a Republican president (or vice versa). In this country, it's not possible for voters to say "I want a Labour government but with David Cameron as PM". Londoners, however, can (if they so choose) have a mayor who is not associated with the party in power. (In 2000, Ken Livingstone was elected as an independent candidate, not as a Labour one).
Chris