Answer: Kings built temples to show their devotion to God and their power and wealth. King Rajarajeshvara built the Rajarajeshvara temple for the worship of his god, Rajarajeshvaram. Here, the names of the king and the god appear to be similar. The king took the god’s name because it was auspicious and he wanted to appear like a god. The largest temples were usually built by kings while the other, lesser deities in the temples were gods and goddesses of the allies and subordinates of the ruler.
The temple was a miniature model of the world ruled by the king and his allies. As they worshipped the deities together in the royal temples, it seemed as if they brought the just rule of the gods on earth. Kings built temples but when they attacked one another’s kingdoms they often targeted these buildings. In the early 9th century when the Pandyan King Shrimara Shrivallabha invaded Sri Lanka and defeated King Sena. he seized all the valuables such as the statue of the Buddha made entirely of gold and other golden images from various monasteries. King Sena II took revenge on this.
He invaded Madurai, the capital of the Pandyas in order to restore the gold statue of the Buddha. In the same way when in the early 11th century the Chola King Rajendra I built a Shiva temple in his capital. He filled it with prized statues seized from defeated rulers. Sultan Mahmud of Ghazni not only seized the valuables from the temples but . also destroyed them. He did it in order to win credit as a great hero of Islam Thus, rulers displayed their political might and military success by attacking and looting the places of worship of defeated rulers.