Don't take a car into the city.
cathedral city in Cumbria, England
The palace is an imposing 1702 sandstone mansion which you can admire from outside but can't visit within. It's owned by the Dukes of Buccleuch but leased long-term to the University of Wisconsin as a study centre. You can visit the surrounding country park free daily 07:00-19:00, but "Fort Douglas" is an adventure park which, ominously, is demand-priced, and costs more for children than for adults.
Dalkeith is a town in Midlothian in the Central Belt of Scotland, which grew up near its 12th C castle (replaced by the 18th C Dalkeith Palace). It's nowadays a commuter town for Edinburgh, which is six miles northwest. This was a coal mining area in the 19th C and a couple of miles south in Newtongrange is Scotland's National Mining Museum.
From the airport, follow ring-road A720 to congested Sheriffhall roundabout then A6106 for the last mile into Dalkeith. You can also take Skylink Bus 400 to Fort Kinnaird on the southern edge of the city, then change to the buses below.
From Edinburgh, use Lothian Bus 3 (& night bus N3), 29, X29, 33 or X33. These start from various points in the western or northern burbs, then run via central Edinburgh, southside and Fort Kinnaird / Royal Infirmary to Dalkeith. From here they continue to Newtongrange, Gorebridge or Mayfield.
Dalkeith used to stand astride the A68 Edinburgh - Jedburgh - Northumberland road, and just east of the A7 Edinburgh - Galashiels - Hawick - Carlisle road. Both roads now bypass town but some buses still call at Dalkeith. The most useful of these is the 51 / 52 from Melrose, Jedburgh and Kelso. Borders Bus X95 stops at Eskbank en route between Edinburgh, Galashiels, Selkirk, Hawick and Carlisle. Long distance coaches (eg from Newcastle and London) don't call here.
East Coast Bus 140 runs from Musselburgh (with buses to North Berwick, Haddington and Dunbar) to Dalkeith and onward to Roslin (for Rosslyn Chapel) and Penicuik.
By rail: Eskbank station is a mile or so southwest of Dalkeith, less convenient than the bus for Edinburgh, but a good option for Galashiels and Tweedbank (for Abbotsford House and Melrose Abbey).
More information available on Wikivoyage