I get the impression that The Dead Poets Society is set in a private school.
Set in 1959 at the fictional elite conservative Vermont boarding school Welton Academy,
high school at Welton Academy, an all male, elite prep school
I assume that the name Welton comes from either the place it is at or the surname of the founder.
There are a number of places named Welton in England, Scotland, and the USA, and Welton is a surname.
If Welton Academy was founded by one or more Scottish-Americans it might have a number of traditions referencing Scotland.
Note that the boys carry vexilloids with vexillums, hanging cloth rectangles, that have St. Andrew's saltires (diagonal crosses), though in different colors than the Scottish flag.
So possibly the script depicted Welton Academy as a Scottish themed school.
Wikipedia also says:
Filming took place at St. Andrew's School in Middletown, Delaware, and at locations in New Castle, Delaware, and in nearby Wilmington, Delaware.
A real school named after the patron saint of Scotland might be Scottish themed, so perhaps the Scottish elements at Welton Academy might come from the real St. Andrew's School.
So I guess that "Scotland the Brave" was played either because the fictional Welton Academy was intended to be Scottish themed, or else because the production found and used Scottish themed features at St. Andrew's School where it was filmed.