The East Neuk of Fife — the cluster of historic fishing villages stretching south and east along the coast — is the most rewarding day trip from St Andrews. Anstruther is the largest and has the Scottish Fisheries Museum and excellent fish and chips at the Anstruther Fish Bar, which regularly tops national rankings. The villages of Crail, Pittenweem, and St Monans are smaller and quieter, with crow-stepped gabled houses in orange sandstone. The entire stretch is walkable via the Fife Coastal Path.
Dundee is twenty minutes by rail from Leuchars and has transformed itself over the past decade. The V&A Dundee — the only V&A outside London — is an architectural statement on the waterfront and the permanent home of the Scottish Design Galleries. The RRS Discovery, the ship that carried Scott to Antarctica, is moored alongside.
Edinburgh is an easy day trip (about 70 miles, an hour by car or 90 minutes by bus), though given how much there is to do in St Andrews, you might find it more sensible the other way around — using Edinburgh as a base and St Andrews as the day trip.
Falkland Palace, a Royal Palace of Scotland used by the Stuarts as a hunting lodge, is about 15 miles southwest. The original royal tennis court, built in 1539, is still playable and is the oldest surviving covered court in the world.