The oldest known use of the term Black Friday is from 1951, where it was used in the magazine "Factory Management and Maintenance." Author M.J. Murphy used the term to refer to the day after Thanksgiving, due to the number of sick calls by employees. Massive numbers of staff would call out sick, which had major negative affects on productivity, so he called it "black Friday" in the sense of "a very bad Friday" ("black" being used in much the same way as for "black Tuesday" - the 1929 stock market crash). Though he used the term again in a similar way later, there doesn’t appear to be any evidence this usage stuck.
The term reappeared a decade later in Philadelphia, where the Philly PD called the two days after Thanksgiving “Black Friday” and “Black Saturday” respectively, due to the giant pain in the neck they were. Traffic was gridlocked, no officers were allowed to take leave, and it was a chaotic mess. The term is here used negatively, as above.
Local merchants in Philadelphia weren’t pleased that the police and newspapers were calling their big shopping day “Black Friday” (since it sounds really bad, as was intended), so they started a campaign to try and rebrand it as “Big Friday.” That didn’t work, since the newspapers continued using Black Friday, but they did manage to change the connotation it had. Somewhere along the line, though it’s not clear where, the idea was put forward that the black in the name was a reference to it being the day retailers move "in to the black" on their accounting ledgers for the year (contrast: "being in the red"), which is to say, they become profitable due to all the shoppers. This explanation doesn’t pop up until much later though, so at best it was a deliberate marketing move by some clever company, though it is just as likely to be a folk etymology developed after Black Friday had shifted from negative to positive connotations.
One thing to be aware of is that, despite online claims to the contrary, the term has absolutely nothing to do with slave trading. That is a recent and patently false internet rumor.