Disclaimer: The following statement should not discourage you from coming to Shul.
Sometimes it's wrong to pray.
Let me qualify that: It is usually the right thing to pray, especially when you've already made the effort to get to Shul. But, sometimes it's not the right thing.
Strangely, when it's the wrong time to pray, we are tempted to pray. The corollary of that theory is true as well: When it's time to pray, we are tempted to chat, engage with our kids, even study Talmud - anything butpray.
So when is it no good to pray?
Logically, the most important times to pray are when you either need help or are inspired to express gratitude to G-d. The most common time that people pray is when they face a crisis. A friend of mine was on an El Al flight that had to make an emergency landing. He says that everyone on that plane, regardless of how secular and including the pilot over the PA system, all said the Shema as the wheels hit the ground.
That story is an amazing illustration of the instinctive, built-in faith that every Jew carries. But, I don't know if the pilot should have been davening right then. He should have been focused on landing his plane.
One of Jewish history's most nail-biting moments happened as the fledgling Jewish nation stood trapped by the Red Sea up ahead and the mighty Egyptian army right behind. Other than surrender to Egypt or commit mass suicide by drowning, they were all out of options.
What would you have done? Prayed?
Moses, as a responsible leader, began to pray. But, G-d cut him off immediately and scolded him that this was a crisis, not a time to pray. Instead of pleading for mercy, G-d insisted that Moshe should lead the people straight ahead, into the sea. G-d's message was: You have a mission to fulfill, to reach Mt. Sinai, don't get distracted, not even by prayer.
A businessman once approached the Tzemach Tzedek, third Rebbe of Chabad, just before shacharis to ask for a loan, so that he could buy some wares at the local market. The Tzemach Tzedek asked him to return after Shul and he would certainly assist him. No sooner had the man left, the Tzemach Tzedek realised that the fellow needed the cash immediately, so he removed his tallis and chased after the man to give him money.
When you need to act, it's inappropriate to pray.
When someone needs you to help them, don't offer to say Tehillim, help them. Prayer is one of Judaism's most powerful tools, but it can never replace action. A Jew should always pray for the wellbeing of others and should always wish others well, but should never fall into the trap of davening when it is time to be doing.