It is because the Indian government pumped enormous amount of money for decades in building defense & related tech in Bangalore.
Tech capitals don't come out of the blue. In the case of Silicon Valley, the US government poured an enormous sum of money in building the tech backbone for their own defense needs. Out came as a result was the tech centre.
Yishan Wong's answer to Why has Silicon Valley proven difficult to copy?
India tried somewhat replicating that.
Stage 1: Setting up the Tata Institute - Swami Vivekananda inspires JN Tata
In 1893, one of India's most popular reformist figures, Swami Vivekananda was returning from a popular trip to the world fair in Chicago.
During the return journey to India, a star entrepreneur, Jamsetji Tata [the founder of Tata group], met the Swami in the ship. Their dialogue must have been stunning enough for Tata to start an institute.
I trust, you remember me as a fellow-traveler on your voyage from Japan to Chicago. I very much recall at this moment your views on the growth of the ascetic spirit in India, and the duty, not of destroying, but of diverting it into useful channels.
I recall these ideas in connection with my scheme of Research Institute of Science for India. Do you think you would care to apply yourself to the mission of galvanizing into life our traditions in this respect? - Jamsetji Tata
Press Information Bureau English Releases
From opium to outsourcing
Sir Ramsay likes Bangalore
India's then viceroy, Lord Curzon liked this idea of a research university and forwarded the proposal to the Royal Society of London. There, William Ramsay , who won the Nobel Prize for discovering noble gases, was tasked with finding a suitable location. Sir Ramsay toured around India and suggested the southern city of Bangalore. He found the elevation of 4500 ft offered a very moderate climate of neither cool nor warm & thus suitable for scientific exploration.
More details here: Sir William Ramsay
Ruled by a great ruler
More than just the climate, the region was ruled by the legendary Krishna Raja Wadiyar IV who was really passionate about education. He was probably one of the best monarchs in India & really a technophile. The kingdom was already ruled by great kings like Tipu Sultan, who understood the value of technology. He also had a great Diwan [Prime Minister] in K. Seshadri Iyer and later Visvesvaraya who both helped setup great institutions.
Together the monarch & his Diwans built a great many things, including Shivanasamudra Falls [Asia's first hydropower plant], University of Mysore, Mysore Medical College, State bank of Mysore, Lalith Mahal palace etc.
Wadiyar and Iyer gave 372 acres of prime land in the center of the city free of cost to setup the new research institution. In 1933, the institute got its first Indian director the Nobel winning C. V. Raman, under whom the institute went to great heights.
This institution, later renamed as Indian Institute of Science, would become the core of Indian research for a century or more. It sort of became the Stanford for India's silicon valley & powered Bangalore.
Stage 2: Indian government invests gobbles of money
The region around Bangalore - Mysore state was a well run state with a high level of education investment and availability of abundant electricity through the hydropower projects.
Bangalore's climate was suitable, the city was welcoming, the infrastructure was strong and also well connected to other major southern metropolises of Madras and Hyderabad with both talent pool & transportation infrastructure.
Thus, the Indian government lost no time in putting all its research investments in the city. Bangalore is the headquarters for:
National Aerospace Labs
Hindustan Aviation Limited
Indian Space Research Organization
Bharat Earth Movers
Hindustan Machine Tools
Indian Telephone Industries
For decades, Indian government put a sizable chunk of its investments in Bangalore. The best part about government investments is that it often constant and immune to changing economic conditions. This sustained public investments created a large tech workforce & a knowledge network that was tapped by waves of tech companies.
Stage 3: Offshoring comes to Bangalore
By 1980s, Bangalore has been already a major education center and a center of research. In 1983, N. R. Narayana Murthy [the cofounder of Infosys] decided to move its fledgling startup supporting IBM mainframes, from Pune to Bangalore, while at the same time Azim Premji [founder of Wipro] decided to setup a software subsidiary in the city. While the rest of India didn't know/care about these new entrepreneurs & busy celebrating the World Cup victory of that year, these Bangalore guys were busy scripting a new era.
In 1984, Texas Instruments setup an office in Bangalore to tap the research pool and that gave further credibility to the location.
Bangalore and India's digital future
But, still the city's tech business was a small thing. Now, time to pull up a notch. The concept of offshoring predominantly took place in a 1989 deal with GE, when Indian government's advisor Sam Pitroda made GE to setup an offshore office in return for getting government aircraft contracts. That office was setup in Bangalore & became the primary core for India's outsourcing boom.
See more details:
Chapter 14: Rice, Cow and Zero: Ancient Indian Triumvirate in new Revolutions
Stage 4: Startup revolution
By the late 1990s, the world was going through a frenzy. Everyone was worried about the Year 2000 problem. This dramatically increased the demand for Bangalore's engineers & there was abundant work. But, the problem passed & there was also a major meltdown in the silicon valley in 2001 after the dotcom crash. A returning pool of unemployed engineers seeded a round of new startups - who started exploring things further beyond outsourcing.
There were also other returning expats who got tired of working for big corporates like Amazon. A couple of them started Flipkart in 2007 - India's answer to online retail. In the same year, a HBS grad got tired of Mckinsey and founded the mobile ad network InMobi.
Flipkart and InMobi did to the Bangalore startup ecosystem what Google and PayPal did in the valley [albeit at a much smaller scale] They unleashed a pool of ambitious, well trained entrepreneurs from their alumni who went on to found various other startups.
India's startup story is still in the making and just two IPOs away from a massive explosion.