Singer/songwriter Al Stewart is known for the detailed historical references in his songs.
His album Between the Wars is practically a textbook of 1918-1939 European and American history set to music (in a good way). The songs detail with such subjects as the formation of the League of Nations and the life of Marian Hearst.
See also "Lord Grenville", "On the Border", and "Flying Sorcery" on the album Year of the Cat; "The Palace of Versailles" on Time Passages; "Constantinople" and "Murmansk Run" on 24 Carrots; "Josephine Baker", "Fields of France", and "Antarctica" on Last Days of the Century; "Trains" and "Charlotte Corday" on Famous Last Words.
Monty Python had a song about Oliver Cromwell. It is, of course, accurate. Once you learn it, you can conjure up all sorts of interesting facts about Mr. Cromwell. (One of my wife's lecturers on the Civil War made the whole class learn the song by heart because it contains so many useful dates)
They also did 'Medical Love Song' which is basically a list of sexually transmitted diseases with their correct medical names (the writer of the song, Graham Chapman, was a qualified doctor. He was in residency when he dropped out to join Monty Python).
When science marched on past their well-known cover of "Why Does The Sun Shine? (The Sun Is A Mass Of Incandescent Gas)," they wrote a follow-up song with corrections.
Manowar's song, Achiles, Agony, Triumph and Ecstasy is an accurate retelling of the Illiad as it pertains to Achiles and Hector. Even using actual quotes from Homer's epic; "stones falls as snow from the sky", for one. Their songs on Norse Mythology are also fairly accurate for a non-Scandinavian Viking metal band, if only due to their enthusiasm for the subject. Odin in particular is basically a retelling of Odin's quest for knowledge, from giving up his eye to Mimir's well and to spearing himself upside down on Yggdrassil for 9 days and nights. Once again, quotations are used; "the will to be a sacrifice of myself unto myself" is indeed how Odin is said to describe his hanging in one of the Eddas.
Iron Maiden has several songs based on historical persons or events that are accurate in their details, including "Aces High", "The Trooper", "Paschendale", and "The Clansman". Singer Bruce Dickinson has, of course, a degree in history.
The Rime of the Ancient Mariner, named for the poem of the same name, is a mostly accurate, if abridged, telling of the tale. It includes several direct quotations- sometimes entire verses, sometimes single lines, or phrases, dropped into the other lyrics.
And a couple other songs refer to literary works, usually with surprising accuracy..."Brave New World" comes to mind.
There's also "Alexander The Great", which mentions the Scythians falling by the River Jaxartes...
Hansi Kürsch does this frequently, with both Blind Guardian and Demons & Wizards probably because he's very much One of Us, a hardcore High Fantasy nerd - with many of his lyrics, practically every phrase is a reference to whatever bit of fantasy, mythology, or history the song is about; figuring them out can be quite fun. On the other hand, the introduction to a song in the middle of a heavy metal concert might not be the best time to start rambling about Richard Wagner's Der Ring des Nibelungen...
Animaniacs did this quite a bit between "The Presidents Song" (US Presidents in order), "Wakko's America" (US states and their capitols), "Yakko's World" (all the nations), "Yakko's Universe" (showing the relative size of the universe), "The Flame" (a gentle re-telling of how Jefferson wrote the US Declaration of Independence, with another episode re-telling the tale of Paul Revere, and still another about Francis Scott Key writing The Star Spangled Banner), "The Planets Song" (the planets in our solar system), "The Ballad of Magellan" and "Bones in the Body", slipping some actual facts into amusing episodes.
The albums Michigan and Illinois by Sufjan Stevens are filled with references to their respective namesakes. Initially, Sufjan claimed that he was planning similar albums all fifty US states, but he's since given up on that (if he was ever serious to begin with).
Sabaton's real-life war songs are very accurate, especially in Wolfpack—who knew failure to launch could be rendered so awesomely?
iLIKETRAINS have lots of historical songs: for example, "Spencer Perceval" and "I Am Murdered" are about the assassination of Spencer Perceval from the perspectives of the killer John Billingham and Perceval himself respectively, "More Weight" is about the death of Giles Corey, "Terra Nova" is about Robert Scott's Antarctic exhibition, "A Rook House for Bobby" is about Bobby Fischer's 1992 match with Boris Spassky and "The Deception" is about Donald Crowhurst's cheating and suicide during the Sunday Times Golden Global Race of 1968-69.
The song "Critical Mass" by British Progressive Metal band Threshold contains a lot of accurate references to particle physics and string theory.
Weird Al Yankovic in "Living with a Hernia". Halfway through the song he starts listing all types of hernias, from incomplete to direct, to a group of medical students.
He did the same with "Pancreas".
Unfortunately, the physics details in that song are off. The attractive force between two pancreases (or any other two objects) is inversely proportional to the square of the distance between them, not the distance.
Professor Tom Lehrer (being an actual professor) did this with a couple of his songs, including "New Math" (an actual subtraction problem explained step-by-step) and "The Elements" (all the known elements of the periodic table at that time).
David Bowie's Rock Opera1. Outside takes place in a Twenty Minutes into the Future setting in which mad artists use violent crimes and even, as the story begins, murder as the basis for works of art. The Bowie-penned short story, "The Diary of Nathan Adler" (Adler being the detective investigating the murder), that makes up the bulk of the liner notes not only establishes the album's storyline and characters, but also weaves in stories of the "precursors" of the art-crime movement. These are mostly Real Life 20th century artists of the offensive and/or True Art Is Incomprehensible schools (Hermann Nitsch, Chris Burden, Damien Hirst, Ron Athey, and Guy Bourdin), and their often-grisly exploits do indeed make the setting more plausible than it might have been otherwise...
Jay-Z's "99 Problems" provides a reasonably accurate analysis of search and seizure in the United States - the only error is that a cop can indeed order you out of the car for any reason. Law professors have been known to use the basic fact pattern in criminal procedure exams.