Use Spell Storing
The most powerful trait for the Shield Guardian is Spell Storing. This is because it can give your party an additional concentration slot with a reasonably high Constitution save. Many party optimizations involve finding ways for your non-casters to concentrate on certain spells; the shield guardian gives you this ability.
Here are a few spells that are very useful for this:
- Haste is probably the best spell for your shield guardian to carry, since it will always be useful. Giving your weapon-fighters extra attacks is extremely powerful.
- Elemental Bane
- Some creatures are resistant to your main spells' damages. Letting your shield guardian concentrate on elemental bane for you will not only remove this resistance, but improve your damage with that damage type.
- If you have low Constitution, your melee fighter (or two with a 4th level slot) might not trust you to keep him aloft to fight a flying enemy. However, your shield guardian will be much more able to maintain concentration.
- Conjuration Spells
- Spells like conjure minor elementals and summon lesser demons are a bit underwhelming since they prevent you from casting concentration spells while they are active, but if your shield guardian casts them, they are much more useful.
Make sure you aren't taking damage though as the Bound trait will make the shield guardian have to make concentration saves when you take damage too.
If you want your Shield Guardian to actually fight...
... you can always use buff spells on your shield guardian to make it more effective. Some of these include enlarge/reduce, haste, and polymorph (for a Giant Ape).
Having your shield guardian cast bestow curse (or similar spells) on a target would also increase his damage output.
Grab 'em and hold 'em
A shield guardian has a fairly high Strength making it a useful grappler even if its damage doesn't scale into the higher levels. This lets you hold enemies in your terrain-modifying spells or just keep them from using positional tactics during combat.
A shield guardian's damage transfer and Shield reaction are very useful defensive features, especially for a vulnerable spellcaster. When you start fighting more powerful creatures, the shield guardian may be better off using the Dodge action and Spell Storing a shield spell to stay alive longer and keep you from taking as much damage. There are also some defensive spells in the cleric list (if you have a cleric ally or are willing to multiclass a bit) that would help with this including sanctuary and warding bond.
Your party's abjuration wizard can also help it stay alive with Projected Ward.
(thanks to @NickBrown in the comments for the idea)