I see that there are some other places like Astrakhan, Rasht, and Makhachkala, but all of them only have about 500,000 people compared to Baku's 2 million. Even historically, there seem to be a real lack of major cities along the Caspian Sea. Looking at a geography map, the mountains between Tehran and the sea may have been a limiter, and the desert/steppe of the eastern bank might have limited settlement. But otherwise, were there historical reasons for this?
This is a really interesting question, and I'm going to give my best shot at answering it. In my past research on the region, I've never found a specific answer to this question, but I can offer a few likely causes:
Of those three reasons, the presence of large oil reserves is the most significant. Once the Russian Empire shifted its economic and military hub there, the city took off, fueled by the oil industry, and its status as the capital of now-independent Azerbaijan. No other city on the Caspian really had that combination of factors at the right time, if you discount Tehran, which is almost close enough to count.
EDIT: Fixed a typo.
Baku, and the Caspian Basin, has been settled for millennia. However it was only in the last decades of the 19th century that the city really grew into something, and there is a simple reason for that: oil.
Oil had been known to be around the region since ancient times. The Zoroastrian, which originates from Iran, makes use of oil-based fires, and the name Azerbaijan (of which Baku is of course the capital) is derived from a Persian name that itself stems from fire (again, based on the excess oil of the region).
But it was only with the development of the modern need for oil in the late 1800s that oil became something of an important commodity. While places like Western Pennsylvania and Texas had the first real oil wells set up, it was in the Baku region that the industry really took off. Baku's first oil wells were set up in the mid-1800s, but with world demand skyrocketing in the latter part of the century, so did the city. I can't find exact figures at the moment (no library access is awful), but the population was less than 10,000 in 1800 but had grown to nearly 200,000 by 1900. It was flooded with workers from across the region: Persian labourers, Armenian merchants, European engineers, Russian government officials, and American businessmen all mingled in the area. Some 50% of the world oil came from Baku by 1900.
Now why did no other city grow and develop like Baku? I would suggest a couple options: first the city was already there. While small when the oil boom started, Baku was still an established port city (albeit on the Caspian Sea, which despite the name is a large lake), with access to Persia, Russia, and Central Asia (not that the latter really mattered at the time). It also was geographically advantageous: though Baku is neatly built onto the Absheron Peninsula, the Caucasus region as a whole is quite mountainous, and there was no direct rail between Baku and Russia until 1880, and even then it was slow going. The terrain was, and is, simply not ideal for massive traffic, and this led to one of the most important developments in the oil industry: the pipeline. The first major pipeline was developed to transport oil from Baku, west across the South Caucasus, to the port city of Batumi (now in southwest Georgia), which would export it to the world. If you look around the Caspian you will see similar issues with terrain: either mountains (to the west, into Russia and the Caucasus, and south into Iran), desert (the east, where Turkmenistan is), or arid prairie (Kazakhstan). None of those are conductive to large-scale settlement.
For some reading on the development of Baku, and the oil industry of the Caspian as a whole, I would highly recommend The Oil and the Glory: The Pursuit of Empire and Fortune on the Caspian Sea by Steve Levine (2007). It looks at the first developments of the region, how it was built, and goes into the modern post-Soviet industry. It gives good insight on the business side of things, and is written by a former journalist so is a really easy book to handle.