I don't think it has ever been established definitively, but here's a theory plausible enough for the TV show. It doesn't require major new historical alterations-- only Edmund's avarice and determination.
In the first episode of the show, Richard III is succeeded by the (fictitious) King Richard IV, father of Edmund, the first Black Adder. What this means for the (real) King Henry VII is unclear. However, since Elizabeth I eventually becomes Queen, it's clear that it wasn't long before the House of Tudor took the throne from the House of York. Later houses-- Stuart, Hanover, etc, probably followed as in the real world.
So how does this relate to the later (fictitious) King Edmund III, the most recent Black Adder?
The Edmund of Blackadder Goes Forth is, as far as we know, a direct descendant of the Edmund seen in the first episode. He (or a later 20th century Edmund) may know this, or he may have discovered it by researching his own ancestry. He could make a plausible claim to be the only surviving heir of the House of York. Making an argument that this gave him a rightful claim to the throne, superior to that of the present House of Windsor, is quite a stretch-- in the real world. Probably impossible, really. But it's exactly the kind of thing any of the historical Edmunds would love to take up. He'd probably argue that the entire House of Windsor were merely pretenders to the throne and therefore not rightful monarchs. We pretty much have to assume he succeeded, based on Blackadder Back and Forth.
This could conceivably take place at any point between the two Blackadder series. I'd guess the most likely time for it to happen would be the end of 1936 or early 1937, right after the abdication of Edward VIII. This led to a crisis over succession and over the state of the monarchy in general-- exactly the sort of confusion where Edmund would make a move. He'd probably start by claiming that Edward VIII had discredited his entire royal house, and work his way up from there.
Why Edmund the third? There was an Edmund II, a thousand or so years ago.
As for Prime Minister Baldrick, the Edmunds always keep the Baldricks around. Getting a Baldrick elected PM would be a natural next move for Edmund III. And anyone devious enough to argue his way to the monarchy would certainly be devious enough to manipulate parliament to serve his ends.