Barry was the third son of Major-General Henry Green Barry, of Ballyclough, Kilworth, County Cork, Ireland, and his wife Phoebe Drought. Barry had five brothers and six sisters and was educated at a military school, near Bexley, in Kent. Returning to Ireland in 1829, he was unable to obtain a military commission so began his own further education. Following his own classics programme, translating classical authors into English verse, reading old and new writers, he gained a working knowledge of nearly every subject.
In 1832, he entered Trinity College, Dublin graduated in 1835 with the usual Bachelor of Arts degree, and was called to the bar in Dublin in 1838.
After his father's death, Barry sailed for Sydney.
Barry arrived in New South Wales in April 1837 and was admitted to the New South Wales Bar. After two years in Sydney, Barry moved to Melbourne, a city with which he was ever afterwards closely identified, arriving at the new settlement on 13 November 1839.
In 1841, Barry served as the defence lawyer for Tunnerminnerwait and Maulboyheenner, two Indigenous rebels on trial for murder. Barry questioned the legal basis of British authority over Aborigines who were not citizens and claimed that the evidence was dubious and circumstantial. Despite his best efforts, the two men were found guilty and subsequently hanged on 20 January 1842, becoming the first people in Victoria to be legally executed.
After the creation in 1851 of the colony of Victoria, out of the Port Phillip district of New South Wales, he became the first solicitor-General of Victoria, with a seat in both the Legislative and Executive Councils. In 1852 he was appointed a judge of the Supreme Court of Victoria. Later he also served as acting Chief Justice and Administrator of the government.
Barry was noted for his service to the community, and he convinced the state government to spend money on public works, particularly on education. He was instrumental in the foundation of the Royal Melbourne Hospital (1848), the University of Melbourne (1853), and the State Library of Victoria. (1854). He served as the first chancellor of the university until his death and was also president of the trustees of the State Library. He was the first President of the Ballarat School of Mines (1870), which later became Ballarat University and is now Federation University.
Barry was the judge in the Eureka Stockade treason trials in the Supreme Court in 1855. The thirteen miners were all acquitted.
In 1857, Barry conducted the inquest into the murder of Inspector-General John Giles Price, who was beaten to death by a group of at least 15 convicts during an inspection of the prison quarries in Williamstown. Seven of the convicts involved in the attack on Price were found guilty, and sentenced to death by hanging. The seven men were executed at Melbourne Goal within a three-day period from 28 to 30 April.
In October 1878, at Beechworth court, Barry presided over a case in which Mrs Ellen Kelly (King) and two men were accused of aiding and abetting the attempted murder of a Victorian Police constable named Alexander Fitzpatrick. After sentencing Mrs Kelly to three years with hard labour, Barry said, "if your son Ned were here I would make an example of him for the whole of Australia – I would give him fifteen years".
In 1880, Barry presided at the final trial of Ned Kelly, who was tried and convicted of murdering three other Victoria Police constables. When he sentenced Kelly to death by hanging, Barry uttered the customary words "May God have mercy on your soul". According to the transcripts, Kelly replied "I will go a little further than that, and say I will see you there when I go". On 23 November 1880, only twelve days after Kelly's execution, Barry died from what the doctors described as "congestion of the lungs and a carbuncle in the neck".