I am planning to play golf at or near St Andrews with a group of other men. What is there for our wives to do while we play golf?
Relax and enjoy St Andrews... It is the University town where William met Catherine. It has a good range of shops as well as the ruined castle and cathedral and a lovely sandy beach...
It is a charming town to explore, and the coastline is beautiful. It's one of the places that I found much more fantastic in person than the tv coverage- it's so flat, so the vistas are wide.
Of course, you do know that when teeing off hole #1 on the Old Course, the area is wide open, and you'll have several hundred spectators watching you hit that crucial first shot! Have a great time!
Have them do the Himalayas Putting Course next to the Old Course. Costs almost nothing and is a great deal of fun, even for non golfers. It is between old course and the water and has a great view of both.
If they feel adventurous, Dundee is about a dozen miles away. There is a branch of the V & A museum.
The #99 bus will take them from St. Andrews to the Dundee train station which is across the street from the V & A.
I spent multiple nights in Dundee in 2019 and liked it a lot. It's not overrun by tourists. The V&A is excellent, and there are several other museums that might appeal to your group. Just Google "museums Dundee".
Another possibility would be a public-bus trip south to the East Neuk villages along the coast--places like Crail and Anstruther. They could take a slow bus that goes through many villages on the way down and return via a faster bus that only makes a few stops.
Another recommendation for The Himalayas putting course. My mom and her friend (both non-golfers) had so much fun doing this while my dad and his golf buddies played the Old Course. I'm hoping to try it out myself if I have time when I visit later this fall. Looking forward to visiting St. Andrews as well! Have a great time!