Hampi has a history from the epical age of Ramayana, ages before the Vijayanagara Empire was born. Hampi has an epical history as the capital city of Kishkindha, the monkey kingdom during the period of Ramayana and an emperical history as the capital city of the Vijayanagara Empire. You can find the introduction of both the episodes here.
Epical History
The epical history of Hampi begins and ends with the Ramayana in Threta Yuga. There are a lot of materialistic proofs in Hampi to show that it might have been the capital of the mighty monkey kingdom - Kishkindha. The whole of Kishkindha Kanda episode of Valmiki Ramayana is built in and around Hampi. This is the very place where Hanuman was born; this is the very place where he met Lord Rama; this is the very place where Vali fought his brother Sugriva.