Mark Twain's A Tramp Abroad (1880) contains some of the most affectionate writing about Heidelberg in English. Twain spent two months here in the summer of 1878, walked the Philosophenweg, drank in the student taverns, and wrote about the castle, the duelling fraternities, and the student prison with the mixture of wonder and gentle mockery that he applied to everything European. The Heidelberg chapters remain the best introduction to the city's character.
Friedrich Hölderlin, who studied at Heidelberg University in the 1790s, wrote his poem Heidelberg (1800), an ode to the city and its river that became one of the defining pieces of German Romantic literature. A copy of it, in German or translation, rewards reading on the Philosophenweg with the view in front of you.
For practical background, the DK Eyewitness Germany guide covers Baden-Württemberg well and includes Heidelberg in detail. The Reclam series publishes a compact German-language guide to the castle and its history, available at the entrance kiosk, that is thorough and reasonably priced.