First a competent and knowledgeable Tech Lead and Project Manager. If those two can not work together and are not good at their job well then the rest of your team is at a huge disadvantage. Now i am not saying they have to be the greatest, but they need to be able to really work together. They are the ones that set time lines, tasks, goals, measure performance, and really set the tone for the team.
You need one or more seniors that not only can do the hard work but they also need to be able to work with and mentor the mid and junior level programmers. I don't just mean hey do the code like this, i mean actually mentor. Spend time doing code reviews and some time teaching them. It would amaze alot of people how much more satisfied a programmer will be if they get this type of feedback and interaction. Programming is not just about writing code, its about learning and improving. That is the only way to move up.
You need something to help bring the team together and build camaraderie. I know it sounds cheesy but a team that is happy knows they people they work with and have built some trust in each other work far more efficiently. Now what to do, well that is very dependent on the people on the team. One place i worked at most the team was into outdoors type stuff, so we went on a whitewater rafting trip. It was alot of fun and we all got to know each other better which lead to everyone working together better.
Those are a few thing that help a team immensely in my experience.
Oh also i forgot to mention, everyone needs to leave their egos at the door when they come to work. Egos are a huge problem and they can cause many many issues.