It all started during WWII. A black market for radios and other electronics developed in the area. It was centered around an electrical engineering school (what's now Tokyo Denki University). After the war, the shops went legit.
For many years Akihabara was the best place in town to buy electronics. These days, there's a lot more competition. Neighborhoods such as Shinjuku and Shibuya now sell more electronics from massive shops that are closer to Tokyo's big shopping crowds.
Akihabara has responded by specializing. It specializes in tourists by offering English configurations and manuals. Akihabara shops also strive to make sales tax refunds easier for tourists.
The other way that Akihabara has specialized is by targeting electronics, gaming and Japanese pop culture nerds (otaku). Many of the electronics shops in the area offer (new and used) parts and hardware of interest to otaku. For example, there's one store in Akihabara that sells nothing but robots and robot parts.
In recent years, an increasing number of shops in the area also sell anime, manga, Japanese pop culture and otaku related items. A otaku entertainment industry has even sprung up. The area is now famous for maid cafes and similar venues catering to otaku tastes.
Pop idol group AKB48 (short for Akihabara 48) has a theatre in Akihabara in which they perform nightly. AKB48's rise to international fame is proof of the growing cultural influence of Akihabara's otaku.