The 1857 war of independence was basically a mutiny of Indian soldiers in the Bengal Army of East India Company. Almost all of the Bengal Army rebelled and a lot of them ended up in Delhi, nominally under the flag of the last Mughal emperor. Bahadur Shah Zafar wasn’t at all eager for the rebellion, but he did give them his blessing when the rebels came to Delhi. Interestingly, most of the soldiers were high caste Hindus from the eastern Hindi belt and not the so-called martial races of India (an idea which probably came later). The British retook India with the help of Punjabi Sikhs and Muslims, Pathans and Gurkhas etc. (here come the “martial races”) and then came the massacres and the hangings. Ironically, the British blamed Muslims for the rebellion when actually it had the support of both Muslims and Hindus.
William Dalrymple is a good writer and the book is a fun read. He creates an image of Delhi in 1857 in your mind and The Last Mughal is worth reading just for that.