It's in the Battlefleet Gothic fluff...
Basically, the Imperium found half a dozen of these things around in deep space, and towed them back to the Gothic Sector. Each station, dubbed 'Blackstone Fortresses' was refitted and turned into a base for the Imperial Navy. They didn't know exactly what the Blackstones were or what they did, but they were able to use them as powerful, almost impregnable starbases, once they were equipped with batteries and lances and their formidable docking facilities were made use of. There was one in each subsector, except for Port Maw. The Imperial Navy was very proud of the fact that no Blackstone had ever fallen in battle.
Then, of course, the Gothic War started. Abaddon's Chaos fleet attacked the Gothic Sector. Abaddon had a pair of C'tan artifacts called the Hand of Darkness and the Eye of Night. With these (although it's questionable what actually allowed him to do it, I'm merely guessing it was the Hand and the Eye), he was able to shut down a Blackstone from a distance. Using this, he was able to capture several during the war. The Blackstones had enormous power once in Abaddon's control, because somehow he had learnt how to use them. With two Blackstones, Abaddon was able to scour the planet Fularis II, destroying all life on the surface, and all that was left was a barren rock. With three, he destroyed the star of the Tarantis system. Fortunately, Abaddon only ever captured three out of the six total.
When the Chaos fleets were defeated and driven back, the Blackstones were lost. The three still under Imperial control self-destructed - I speculate that Abaddon ordered them to, with his C'tan artifacts, though there's no real evidence on what did it - , and of the three controlled by Chaos, Abaddon successfully retreated with two back to the Eye of Terror. The last one was surrounded by the vessels of the Imperial Navy, bombarded, and destroyed.
(All of this is found in the Battlefleet Gothic rulebook)
More recently, in the 13th Black Crusade, the two surviving Blackstones were in the vanguard of Abaddon's fleet. This time, the Necrons sought direct conflict with Abaddon, in order to destroy them. The Necrons essentially failed in this. Eldrad Ulthran lead an Eldar strike force from Craftworld Ulthwé to recapture one, but failed and was taken by Slaanesh. After Cadia held out and Abaddon retreated back to the Eye of Terror, he took the two Blackstones with him.
They're still there now.
(This is from the Eye of Terror campaign)
As to where they came from originally - the Eldar call them Talismans of Vaul, and believe that their god Vaul forged them and gave it to the Eldar in order to fight the C'tan. It's also possible that the Eldar built them themselves in the distant past, or the Old Ones built them as weapons and gave them to the Eldar for the war.
To what they do - As mentioned, the Imperium used them as military bases. Their original purpose was to destroy the C'tan, using a powerful Warp cannon. However, I contest that you can't destroy a C'tan any other way. The Blackstones are specialised to be good at it, but any Warp-based power could do it, or you could simply destroy the Necrodermis and keep it from reforming.