Ahalya was the wife of Rishi Gautam. She had a son from Surya or sun God and his name was Sugriv. She had another son from an illicit relation with Indra. That son was Vali. Her husband Rishi Gautam turned her into a stone (cursed her) and told her she will become alive again when God Ram touches the stone with his feet.
The two sons were cursed to become Monkeys. Vali moved to a certain area called Kishkindha and became a King there. He was challenged to a fight from a Demon Mayavi and they went and fought in a cave. Sugriv was outside the cave and he heard cries and then saw blood coming out of cave. He thought his brother was dead and became the king. But Vali was not killed. He was furious and thought his brother betrayed him and banished Sugriv to Rushimukh. Now Vali could not enter Rushimukh due to a curse placed by Rushi Matangya
When Sita was abducted by Ravana, Ram sought the help of Sugriv. Sugriv said he would help if Ram helps him get his Kingdom back. Sugriv and Vali had a battle but both were equally strong and neither could win. Often times it seemed like Vali had the upper hand
Ram said he would intervene. But both brothers looked alike. So Ram told Sugriv to wear a garland of flowers and then fight. Ram sat on a tree and at the end of 3 days, had a clear shot and took an arrow and killed Vali
Hanuman introduced Sugriv and Ram
Now this is a very spiritual story with many secrets revealed.