Why is a judge or magistrate called "the beak"?

I don't know but the 1911 Encyclopedia Britannica says

The slang use of "beak" for a magistrate or justice of the peace has not been satisfactorily explained. The earlier meaning, which lasted down to the beginning of the 19th century, was "watchman" or "constable." According to Slang and its Analogues (J. S. Farmer and W. E. Henley, 1890), the first example of its later use is in the name of "the Blind Beak," which was given to Henry Fielding's half-brother, Sir John Fielding (about 1750). Thomas Harman, in his book on vagrants, Caveat or Warening for commen cursitors, Vulgarely called Vagabones, 1573, explains harmans beck as "counstable," harman being the word for the stocks. Attempts have been made to connect "beak" in this connexion with the Old English beag, a gold torque or collar, worn as a symbol of authority, but this could only be plausible on the assumption that "magistrate" was the earlier significance of the word.

Businessballs has a longer entry on the subject.


Theories regarding the origin of 'beak' in the sense of 'magistrate'

J.S. Farmer, Slang an Its Analogues Past and Present (1890) has a lengthy entry for beak, some of which the 1911 Encyclopedia Britannica cites in its discussion that RedGrittyBrick cites in another answer here. Here (at greater length) are some of Farmer's comments on the meaning and possible origin of the slang term beak:

BEAK, subs. (old cant).—1. A policeman or guardian of the peace. As far as is known, this (as 'beck') is the oldest cant term for a member of a class of men, who, perhaps, above all others, have been the recipients of nicknames and epithets, and these, be it noted, not always of a complimentary character. In Harman's Caveat (1573), harman BECK is explained as 'the counstable,' harmans being 'the stockes.' The derivation of BECK or BEAK is doubtful. Especially vague seems that which finds its source in the Saxon beag, a gold collar worn by civic magistrates, and an emblem of authority. This genesis appears to be based on the later and secondary sense of BEAK, a magistrate, a meaning which it still retains. But, against this must be placed the fact that, as the name for a watchman or guardian of the peace, BEAK boasts a much older usage. Sir John Fielding, half brother of the author of Tom Jones, and an active Middlesex Justice in the last century, was popularly known as the 'Blind Beak' [c. 1750] ; but beyond this date no instance of this sense has been found. If, therefore, BEAK originally signified a policeman, it is difficult to discover any connection with the Saxon beag, inasmuch as watchmen are not known to have been decorated with gold collars.

...

  1. (popular.)—A magistrate. Cf. foregoing, much of which has reference to this secondary meaning of BEAK. Sometimes called A BEAK OF THE LAW.

...

  1. (popular.) — The nose. ... [First cited instance:] 1598. FLORIO. Naso adunco, a BEAKE-nose. {M.}

...

  1. (Eton and Marlborough Schools.)—A master.

Frank Milton, In Some Authority: The English Magistracy (1959) [combined snippets] asserts that the English slang term beak is of Dutch origin:

Until very recent years a very common expression to describe appearance before a magistrate, especially in London, was 'Up before the Beak', but the word and phrase now appear to be on their way out. Beak, or Beck, is an old word, of Dutch origin, for anyone in authority (masters are still ‘beaks’ at some public schools); from the sixteenth century it was used to describe a constable, and it was partly by an accident of alliteration that the term, as applied to a magistrate, survived. Sir John Fielding, who succeeded his half-brother, the novelist, as Chief Magistrate at Bow Street in 1754, was blind. A magistrate in those days, at Bow Street even more than elsewhere, was as much a policeman as a judge, so it was inevitable that he should become known as ‘The Blind Beak’. The name stuck, and still sticks, though less firmly than before. Today it is certainly used more by the old than by the young, and more in London than elsewhere. ‘Stipendiary Magistrate’ is the correct title of the legally qualified magistrates in the provinces; it is sometimes abbreviated to the inelegant but affectionate ‘Stipe’, but this word, like ‘Beak’, has now acquired a rather dated sound.

The close connection between constables, police, and magistrates is suggested by this excerpt from Stephen Inwood, Historic London: An Explorer's Companion (2008):

In Soho, 19–21 Great Marlborough Street (off Regent Street and opposite Liberty's) is a J.D. Butler magistrates' court and police station of 1913, now converted into the Courthouse Hotel (with its own prison cells), and a short walk down Carnaby Street and a left turn into lively Beak Street brings you to a J.D. Butler police Section house of 1909, at number 40.

That Beak Street was the site of both a police court is evident from William Makepeace Thackeray, "Hobson's Choice," originally printed in Punch (January 1850), reprinted in The Works of William Makepeace Thackeray, volume 26 (1886):

Mr. Abershaw swore more than ever that he was innocent, and called upon me to swear that I had seen him in the pit of the theatre during the whole of the performance; but I could neither take my affidavit to this fact, nor was Mr. Scroggins [a police detective] a bit satisfied, nor would he be until he had the man up to Beak Street Police Court and examined by the magistrate.

But whether Beak Street has any direct connection to the slang term beak is unclear. The earliest mention I could find of the street is from Robert Seymour, A Survey of the Cities of London and Westminster, Borough of Southwark, and Parts Adjacent, volume 2 (1735), which finds it most notable as the location of "Pott's-yard, a pretty large Place for Stabling and Coaches." But a later survey of London, London and Its Environs Described (1761) reports this:

BEAK street, Swallow street, Piccadilly, so called from most of the houses belonging to Col. Beak.

Unfortunately, I have not been able to find any further information about an eighteenth-century Colonel Beak, beyond a mention in "Historical Chronicle, August 1742," in The Gentleman's Magazine of a "Lieut. Col. Beake, Member of St Ives,———Aid de Camp extraordinary to the Forces," who received promotion to that post in 1742.

Eric Partridge, A Dictionary of Slang and Unconventional English, First Edition (1937) suggests that the slang term beak is of French origin:

beak. A magistrate : C. 18–20. In C, 16–17, the form was beck, the meaning a constable (a sense lingering until ca. 1860); also it was c[ant], as beak itself was until a. 1850, since when the most frequent use has been up before the beak, on trial by a magistrate; in the G[reat] W[ar] this phrase = before the orderly officer. ... All senses probably ex Fr. bec, a beak.


Early instances of 'beak' in Google Books

In Google Books searches, the oldest published reference to beak as slang for "magistrate" appears in "The Oath of the Canting Crew" (1749), in J.S. Farmer, Musa Pedestris: Three Centuries of Canting Songs and Slang Rhymes (1536-1896) (1896):

I, Crank Cuffin, swear to be/True to this fraternity;/That I will in all obey/Rule and order of the lay./Never blow the gab or squeak; Never snitch to bum or beak; ...

Farmer reports that the last line means "Never betray [secrets] to bailiff or magistrate."

And from John Poulter, The Discoveries of John Poulter, alias Baxter (1754):

A rum Beak ; a good Justice. A quare Beak ; a bad Justice. A scribing Gloak to the Beak ; a Clerk to the Justice. A Horney, a Scout ; a Constable, a Watchman.

This last occurrence is especially interesting in strongly suggesting that, in the London cant of 1754, beak referred to a magistrate but not to a constable.