Did Britain make an error by not allying with Germany in the late 19th century? From the British perspective at the time: no, because there was no compelling reason to ally with Germany, and there were several reasons not to do it. Looking back at the history of the World Wars, I can (and would) however defend the position that if Britain had allied with Germany, this could have been in Britain's favour. Consider, first of all, that the situation is as follows:
-- Britain's commitment to "balance of powers" has been grossly overstated by many historians, who all suffer from some pretty dreadful confirmation bias. Britain did clearly prefer such a balance, but was far from eleveated above some nice opportunism. If at any point it had really seemed like ganging up with Germany would be to Britain's clear benefit, the "balance" could've buggered right off.
-- Moreover, it wasn't at all clear that Germany was absolutely the "stronger" party that Britain had to side against. Nor was France by definition the natural ally. There was a very active (and even pretty duplicitous and manipulative) Francophile element in the British leadership, but that was a minority. Most Britons, as well as most British leaders, preferred moderate isolation and neutrality. Especially after Crimea. ("Britain should stay out of the continent's stupid wars.")
-- Germany itself, though, made things difficult. Wilhelm II was an oaf. Not the psychopathic tyrant he's sometimes painted to be, but a man without any decent feeling for social or interpersonal relations and nuances. He pissed people off without intending it, and he often felt personally slighted by people who had done nothing to him. His foreign royal cousins weren't fond of him. Germany also insisted on colonialism, and on building an oceanic fleet. Both felt like threats to Britain. Not that Germany could win that race, but it indicated a certain intention.
All of this means that an Ango-German alliance in the late 19th century was certainly possible, but not necessarily likely. Germany's behaviour painted it as more of a "rising rival" than other powers, and Kaiser Willy II fucked up all diplomatic efforts again and again. Still, though, it ultimately took German violation of Belgium's neutrality to give the pro-French and anti-German elements in Britain's leadership the momentum needed to commit Britain to the side of France and Russia. This strongly suggests that an alternative, Anglo-German(-Austrian) alliance was not at all impossible in the late 19th century. There are some more facts to consider in that context:
-- Throughout the 19th century, Britain has been in a rivalry with Russia over influence in Asia. This rivalry was not always purely confrontational, the two powers occasionally colluded via diplomatic efforts, and there were successive treaties and agreements between them. The so-called 'Great Game' is widely held to have ended in 1895. It may at least be argued that after this point, Anglo-Russian co-operation in any major conflict would hardly be an incredible thing. But even before, the rivalry was winding down, and the right circumstances have brought Britain and Russia into a common pact.
-- There was likewise Anglo-French rivalry, resurging after the muted nature of the post-Napoleonic period. This culminated in the Fashoda Incident of 1898. After that, Britain and France made efforts to reach greater accord. This may be said to have culminated in the Entente Cordiale.
-- Germany was, for quite some time, planning its strategy around a "League of Three Emperors" between itself, Austria-Hungary, and Russia. This was chiefly because Bismarck really wanted to prevent Russia and France from ever being on the same side. The first League lasted from 1873 to 1878. A second one existed between 1881 and 1887 (having been renewed in 1884). In the end, the Germans let it lapse. Bismarck, despairing, salvaged what he could via the Reinsurance Treaty of 1887, but upon his dismissal as Chancellor in 1890, this wasn't renewed either.
Given these facts, if Anglo-French relations turned sour to such a degree that a conflict erupted in (most realistically) the period 1881-1887, it is realistic for Russia, Germany and Britain to be on one side (along with Austria-Hungary). Even though Willy II was an oaf, it's certainly not like Britain was somehow allergic to Germans or something. If a war with France broke out, and alliance with the Germans would be great. And if this happened in such a handy time-frame as to keep Russia from allying with France... so much the better!
Such a war would be over very swiftly, and this would be beneficial to a) everybody in general and b) the victors in particular. So we may therefore argue that this would have been better for Britain. There wouldn't be a whole generation dead in the trenches, the Empire wouldn't get a fatal blow, and Britain would just be better off in general. With a quick, overwhelming victory (probably leading to a firm but none-too-cruel peace), the chances of a second Great War would also be diminished. And without American involvement, the USA's take-over of absolute unquestioned supremacy among the world's great powers would also be a bit delayed. All in all, very good for Britain.
But allthis requires an engineered ATL situation where an Anglo-French conflict breaks out at the right time. Such a coflict didn't break out in OTL. If it had, the resulting timeline might well have worked out better for Britain than OTL did. But since it didn't, I really don't think we can argue that Britain "fucked up" by not allying with Germany.
(Britain did fuck up in joining the First World War. If Britain had just stayed out of that, all its rivals could have beaten each other bloody, while britain got out without a scratch. Allowing itself to be dragged into the mess was a clear error, and those who made that call can be blamed for that, because there were plenty of people around to warn them. They just didn't listen. But that's a post-1900 discussion.)