The Heir of Linne (Child ballad #267; Roud #111) is a traditional folk song existing in several variants.
No one will lend him money, and he realizes his folly: he could have lived comfortably on his lands.
He remembers a letter that his father left him, or a key that his mother gave him, or tries to hang himself and splits the roof.
He goes back to his old hall, and tries to borrow money from the new owner, who jeers at him, and mockingly offers to sell back the lands for less than the purchase price.
This appears to be written by Thomas Percy in his Reliques of Ancient English Poetry, rewriting an older ballad with some ideas taken from a second ballad.