There are tons of ways to answer this question. Here are a few reasons:
First, we're told we should:
Let us hold fast the confession of our hope without wavering, for he
who promised is faithful. And let us consider how to stir up one
another to love and good works, not neglecting to meet together, as is
the habit of some, but encouraging one another, and all the more as
you see the Day drawing near.
Second, I think within the church we learn how to love one another. People in the church are... well... people, so they're by definition going to be just as flawed and screwed up as anybody else. This is going to cause friction, and is going to force us to decide if we want to give people grace, or if we want to judge them for the areas they fall short. In the church we can learn patience in an environment that offers grace.
Thirdly, it's a way we can encourage other believers as well. You can't encourage another believer if you never spend any time with them. Also, the church gives us confidence in our walk with God. People outside the church may not understand why we do the things we do or don't do the things we don't do. People inside the church do. As an example, if my boss asks me to do something unethical, he may not understand why I choose not to do something like that. If, as a result, I lose my job, then the church is there to support and encourage me during those times. I'm not just "out on my own".
I'm certain there are tons more reasons, but those are a few.
As to the verse you quoted, from Matthew 6:5, this is referring to specifically showy displays of piety, not honest, heartfelt displays of affection towards God from a soul that has been completely and totally crushed by the law and is crying out for God to have mercy. In other words, it's about self-righteousness, not approaching God as a beggar asking for the righteousness that only He can give through Christ. The church should be a gathering of those beggars looking for a handout from God.