u/JDHoare gave a very detailed answer to this question here.
I'd only add that Roman Polanski's adaptation of Rosemary's Baby was a crucial step in the popularisation of the association of this image with satanism. It's made occasional appearances in satanist groups and texts since then but the inverted pentagram is generally the preferred symbol.