Forretress has an easy time setting up Spikes, making it a good choice on standard teams; it can also Rapid Spin, which is always a plus. However, Forretress has one really, really big problem: its offense blows. It has to resort to type advantages from Hidden Power Bug and Earthquake, status from Zap Cannon or Toxic, or Explosion to pose any sort of a threat. While its excellent resistances make it a great wall, Forretress is easily rendered useless by threats with a setup move.
In addition, Forretress faces competition as a wall from Skarmory, which has the advantage of phazing capability and Flying-type STAB; the former lets it take advantage of the entry hazards it sets up while the latter enables it to keep Gyarados and Heracross at bay. Forretress, on the other hand, can barely touch them outside of Explosion, Hidden Power, or Zap Cannon. Furthermore, Skarmory is a better bet against most physical hitters, as it is immune to Ground, resists Flying, and 4x resists Bug, while Forretress takes neutral damage from Ground and Flying and only has a 2x resistance to Bug. Forretress has the slight advantage of having only one weakness as opposed to Skarmory's two, namely to Fire and Electric. However, Forretress will be OHKOed by any Fire move because its weakness is 4x, while Skarmory will usually survive one unexpected Thunderbolt or Flamethrower. All in all, if you want Spikes and Rapid Spin on your team or need a Pokemon that both walls Metagross and can actually hurt it, Forretress is your friend. As long as you know where it shines (walling and utility) and where it sucks (stopping setup), it will be a welcome addition to your team.
Forretress doesn't have many weaknesses, so setting up Spikes should be a manageable task. Forretress can also Rapid Spin opposing Spikes away, but beware of Ghost-types. Hidden Power Bug provides STAB that hits Tyranitar, Starmie, Celebi, and random switch-ins such as Blissey. Earthquake can be used to repel Magneton and keep Metagross at bay. Explosion is for when Forretress's job is done, namely when the opponent's Spikes or Rapid Spin user is removed, you have enough Spikes yourself, and you no longer need Forretress's walling capabilities. Alternatively, Toxic can weaken some of Forretress's switch-ins and really hurt Cloyster if your opponent is relying on it for Rapid Spin.
Maximize HP and Special Defense; it allows Forretress to set up Spikes in the face of special attackers like Milotic and Regice much more easily. The Special Defense is also a major ally when facing Starmie, which normally threatens Forretress with Surf. A more physically defensive spread can be used to set up on physical attackers, but because many of them set up so easily, Forretress can easily find itself having switching out every time they come in to prevent a sweep. Specially defensive Forretress can also manage versus Magneton and Jirachi much easier, especially if using Earthquake. That being said, don't rely solely on Forretress to keep Jirachi at bay—its high defenses and ability to Calm Mind will eventually take out Forretress, but in most cases it will want to avoid allowing Forretress to set up all three layers of Spikes.
Zap Cannon can paralyze the likes of Skarmory, Gengar, Gyarados, Salamence, and Cloyster, but Heracross sponges it easily and might even gain a Guts boost. Reflect and Light Screen can provide a useful boost to your team's defenses; the latter is especially handy as most people will switch in a special attacker. For instance, Light Screen enables Forretress to survive Magneton's Hidden Power Fire and OHKO it with Earthquake. Forretress survives even attacks from +6 Snorlax and OHKOes it with Counter. Hidden Power Flying lets Forretress take on Heracross and Breloom. Protect grants Forretress extra Leftovers recovery, but more importantly allows it to scout Snorlax and Salamence for Fire-type moves. Hidden Power Steel provides STAB and is the best option against Gengar bar Hidden Power Ghost, which won't do anything to Tyranitar.
Although specially defensive Forretress is overall better, the physically defensive spread certainly has its uses. For instance, Forretress with Counter or Forretress used to check Tyranitar or Metagross would certainly appreciate the physical bulk. Although a specially defensive Forretress can tank a +6 Earthquake from Snorlax, a physically bulky Forretress can survive even a +6 STAB Hidden Power Flying from Salamence or Gyarados! Especially on stall teams, where they most likely possess plenty of answers to special threats in a form of special sponges like Blissey, Forretress's physical defense would be more appreciated.
Checks and Counters
The best counter in the game to Forretress is Gengar because it is immune to Rapid Spin and packs powerful special attacks in addition to a base 130 Special Attack. In general, all Ghost-types ruin Forretress just by virtue of blocking Rapid Spin. Opposing spinners also trouble Forretress. Claydol is immune to Earthquake, Zap Cannon, and Spikes, but it is weak to Hidden Power Bug and hates Toxic. Donphan isn't scared of anything but Toxic. Gyarados can Taunt and freely set up Dragon Dance boosts for a sweep if Forretress lacks Counter or Zap Cannon. Whereas Salamence cannot Taunt and therefore allows Forretress to lay Spikes, it often packs Fire Blast or Flamethrower. Even if it doesn't, Forretress can't do much of anything to Salamence. Forretress also can't get past Heracross without using Hidden Power Flying. Magneton can trap Forretress, but has to be wary about Earthquake.