McCartney had the struggle of black women especially in mind when writing the song. In his 1997 book, Many Years From Now, McCartney said of Blackbird: "This was really a song from me to a black woman, experiencing these problems in the States: 'Let me encourage you to keep trying, to keep your faith, there is hope.'"
https://www.bbc.com/culture/article/20240329-beyonce-cowboy-carter-the-beatles-blackbird