In the early 19th century, the quality of London's air was so bad that acidic carbon fumes ate into the varnishes of oil paintings, scarring great masterpieces for ever. If you had a Rubens or two, it was wise to get them out into the country, away from the effects of the industrial revolution. It was this that made the art dealer Noel Desenfans and his companion Francis Bourgeois choose Dulwich – a sleepy place then, outside the capital – as a permanent home for their collection. Today, the two founders of Dulwich Picture Gallery lie entombed in the building. You pass through the mausoleum in Best of British, a lovely new exhibition with a lousy name that tells how this gallery ended up with such an eccentric, rich and thought-provoking collection of British paintings.  Desenfans and Bourgeois didn't actually collect British art. They founded Dulwich to house their European masterpieces, by Rubens, Rembrandt, Guido Reni. British art was still just beginning to be taken seriously. But somehow (the show's title could refer to something like the best of British luck) this gallery ended up with a very special British collection. The core of it was already at Dulwich College, the school the art gallery was originally attached to. The portrait of the college's founder, actor Edward Alleyn, is one of the first things you see here. Alleyn is a massive, imposing character with red face and big beard (you can see why he was such a success in the role of Christopher Marlowe's world-conquering warrior Tamburlaine). Portraits of other 17th–century actors – one is thought to show Richard Burbage, the first Hamlet – also come from Alleyn's collection.  The exhibition, which ends with a Constable bought in 2006, is full of intriguing oddities and genuine masterpieces. The oddities include an anonymous 16th-century portrait of a couple called the Juddes, who place their hands on a skull while contemplating a corpse. The masterpieces include 18th-century painter George Knapton's portrait of black-eyed Lucy Ebberton, dressed in an expensive shepherdess outfit, and an unusually gentle picture by the satirist William Hogarth, of a woman fishing.  But what struck me – in the tranquil setting of a gallery that, although now within London, is still pastoral or at least suburban in mood – was how these works seemed to unite in a common theme, even though they were assembled over centuries. Once you have passed the earliest works, with their terror of mortality, the art all points in the same direction: towards the countryside. Even the portraits – Lucy Ebberton's garb, Hogarth's fishing party – breathe country air. British art, you start to suspect, has had a long love affair with the idea of pastoral escape.  This is what makes one painting in the show stand out: a haunting 17th-century portrait of a shepherd boy who has lowered his flute and, resting against a rock, stares dreamily into space. From his shady spot, he responds sensitively to the soft wildness of the landscape. Yet something isn't right. His face is golden, his lips are red, his long brown hair is far from straggly, and the robe over his loose white shirt looks more courtly than rustic. In fact, the more you look at Sir Peter Lely's A Young Man as a Shepherd, the more its pastoral setting seems artificial – and its meaning more poetic.  This gentle vision was painted in one of the bloodiest periods in British history. Lely, who was born in Germany, came to Britain in the 17th century, succeeding Anthony van Dyck as the country's most fashionable portraitist. He chose a dangerous moment to work for the British court: instead of portraying Charles I in one pose after another, he lived through the civil war and the beheading of the king in 1649.  In this context, Lely's painting could be read as a dream of escape. This young man, who looks more dreamy poet than toiling shepherd, is surely an inhabitant of Arcadia, that utopian vision of pastoralism where shepherds play the pipes and nymphs dance. The youth of Britain, in Lely's time, did not live in such a place: Cromwell's head was stuck vengefully on a spike after the Restoration, while religious fundamentalism and class war ran riot. Lely's masterful painting was a flight from chaos into a tranquil world.  What are we to make of his other Arcadian fantasy at Dulwich Picture Gallery? Although it is not part of this show, Lely's Nymphs By a Fountain (which hangs in its usual spot) really is the best of British, one of the most subversive paintings of the nude in European painting.  Five young women slumber naked around a fountain in an Arcadian woodland. The golden light on their bodies echoes Titian, several of whose paintings Lely bought at the sale of Charles I's goods after his execution. Nymphs By a Fountain was painted in about 1650 – just after the king was killed – and it is at once lyrical and brutal. Reality has entered Arcadia. The nymphs are women; their bodies are not idealised.  The same pastoral dreams linger in another current exhibition, this one at Nottingham Castle's art gallery. In Paul Sandby: Picturing Britain, the whole of Britain has become an Arcadia, peaceful and untroubled. Sandby, a Nottingham-born watercolourist, was one of the many successful artists of Georgian Britain. In 1761, his friend Francis Cotes portrayed Sandby leaning out of a window, sketching the landscape beyond. In his gold waistcoat, white shirt and violet coat, he looks every inch the gentleman artist.  In Cotes's painting, Sandby is doubtless within one of the many great houses whose estates he and his brother Thomas sketched. Sandby made precise and loving watercolours of, among others, the Earl of Bute's Luton Park, landscaped by Capability Brown. He also became one of the most popular drawing masters of the 18th century, always in demand when it came to teaching aristocratic women how to sketch scenery, a popular pursuit. In his view of Roslin Castle, painted around 1780, we see Lady Francis Scott drawing her own view of the shadowy rustic valley.  The idea of Arcadia is as glaring in Sandby's art as it is in Best of British. But it has become anodyne – and consciously so. There is only one eruption of anger in this show. In a series of bitter satires, Sandby pours vitriol on his rival Hogarth. He caricatures him as a deformer of nature, exhibiting a magic lantern show of low-life monstrosities. In other words, Sandby is saying that Hogarth's pictures of London are ugly lies. The truth, he claims, is calm and beautiful. In his views of London, the city is stilled and perfect. Laundresses happily balance baskets on their heads as they walk towards the golden morning.  British art, these exhibitions show, abounds in landscapes of pleasure. Behind the art of both Lely and Sandby lies the history of the English country house, the nation's dominant cultural institution for centuries. Landscape gardens begat Arcadian art. And no one has ever painted more beguiling Arcadias than Sandby's 18th-century contemporary Thomas Gainsborough, whose works star with Lely's in the show at Dulwich Picture Gallery.  Gainsborough's works are the ultimate pearls of the British collection in Dulwich. In Best of British, they glow. His early painting An Unknown Couple in a Landscape shows a man in a glaring red waistcoat and a woman sketching in an East Anglian field that seems about to be dashed with rain from the gathering clouds: this painting aches with a sense of place.  Gainsborough's later portrait of the Linley sisters is just as intense in its rendering of place, but this place is not real: it is an idyllic and sublimely hedonistic idea of nature, compounded of country parks and poems and perfumed longings. Out of a fantastic bower, a fairytale setting for fairytale princesses, gazes Mary Linley, with a directness that makes the mood electric. It's a good counterpoint to Sandby's work, which can sometimes feel like a tame stroll over a rich man's estate. Gainsborough painted women as if he was their lover. In this painting, that is giddily explicit.
Two new shows reveal how artists such as Gainsborough, Sir Peter Lely and Paul Sandby depicted a golden, escapist Britain. By Jonathan Jones