Our Scriptures and Puranas (epics) contain material that helps in strengthening our mind. It is stated therein that Puja done whether at home or at a temple helps the person acquire merit (punya).
Take the case of the person who visits the temple not out of his will but due to the persistence of a friend. He is merely doing this action to please the friend. It is an action driven purely out of friendship. Even then it results in multiple benefits!
First and foremost, the friend is tremendously pleased that you have accompanied him to the temple. He believes that you, like him, have a faith in God and that therefore you are basically a good person. Secondly, you will get good thoughts. Good thoughts lead to good feelings. Thus this visit has benefited you both physically and mentally. At a physical level your friend has believed that you are basically a good person. On the mental plane, you could get good thoughts and good feelings. These benefits are termed ‘punya’ in our religion. Therefore although your visit was merely to please your friend, you were rewarded with punya. Hence it cannot be a sin. Gradually, as you keep visiting the temple albeit without faith, you will be acquiring mental peace and concentration. This is an additional benefit accrued to you, the benefit of which will be reflected throughout your life. That is why it is important to spend time in puja, homa, dhyana etc.