Our ultimate goal in life should be to reach god. But there are 3 obstacles that will prevent us from attaining our goal. They are called as 3 malams. They are ego (ahankaram) , illusion (maya) and deeds (karma). One need to get rid of these three inorder to reach god.
The first step for achieving this is to start paraying to god. For that we are going to temple. Many may ask, why should we go to temple for praying to god, when he is present everywhere (omnipresent). Going to temple is like doing tapas or meditation. In this world there are lot of things that will kill our concentration. So we need a place where our attention is not diverted away from god. Temple serve for this purpose. We are not great saints to hold our concentration for a long time without getting deviated. Even the saints in ancient time will go to punya sthalas and theerthas for meditation.
The sages at naimisharanya who were devoid of the three malams mentioned above were unhappy as they were not able to understand the inner meaning of vedas. A new sage comes to naimisharanya and understanding their worries asks them not to feel bad. He also says that they need to do tapas and it should be done at a place where they can interact with god one on one. The sages asks the new saint himself to suggest a place and he suggests them all to go to Madurai and sit infront of the dakshinamurthy who is none other than lord shiva manifested as guru.
The sages then go to madurai and understand that Lord shiva is the essence of vedas. Detailed explanation is given in my other post. Click here to read it.