What is the best product for repairing expanding gaps in a brick wall?
Three inch gaps seem quite large - even for a 300 year old wall.

You just need to use a good mortar mix (sand and cement) on the narrower gaps.

Clean out all the old, lose material first to make sure that you get good adhesion and then push the mortar right into the gaps as far as it will go. Work on a small area (1 m2) at a time.

Adding pea gravel to give the mix more "body" might work on the wider ones.

However, I'd get a professional to have a look at the wall first to make sure you're not going to have to redo this work in a couple of years time. If the foundations have gone it might need something more substantial work doing.

Is the wall part of a house or just a garden wall? If it's the latter then dismantling and rebuilding might be the best long term option.