The imposing grey palace of San Lorenzo de El Escorial is a great destination for a half a day away from Madrid. The unornamentally severe palace was intended to serve as a mausoleum and a contemplative retreat, rather than an opulent country residence.
The royal apartments are quite humble, but the main attractions of the palace are its artistic wealth and the splendor of some of its main purposed rooms, especially Library ♥♥♥, which holds forty thousand books in twelve languages, Basílica ♥♥, with a lavish altarpiece, Royal Pantheon ♥♥♥, with the funerary urns of Spanish monarchs, and Sala de Batallas ♥♥, with walls and the ceiling covered in paintings depicting various battles. The Museum of Art contains a number of Flemish, Italian and Spanish paintings.
The palace is huge, and touring it with an audio-guide takes around three hours at a minimum. The village, over which the complex towers, is rather nondescript.
Most frequent train services to El Escorial are from Chamartin, which is near a metro station Bambú. The train ride takes about 50 minutes. Upon arriving in El Escorial, you may want to walk uphill to the palace on your own, or to take a municipal bus. I recommend the latter; leave the walking bit for the return leg.