The best resource for understanding the historical context of Gurbani would be the Amritsar Taksal's commentary on Guru Granth Sahib, Amir Bhandar. All volumes of the commentary are available: https://archive.org/details/amir-bhandar-teeka-01/mode/2up Faridkot Tika also provides some information regarding the historical context of certain compositions, you can display the Faridkot Tika on SikhiToTheMax.com. The Giania Bunga in the 18th century wrote a text, ਉਥਾਨਕਾਵਾਂ, which briefly mentions the historical context of various compositions in [[Adi Guru Granth Sahib/Adi]] Guru Granth Sahib, and this tradition of providing this information has flowed from generation to generation within traditional learning institutions (ਸੰਪ੍ਰਦਾਵਾਂ).