A slogan, intended to alert children to the risks posed by people they do not know.
This term arose in various campaigns which ran in the USA in the 1960s, which later spread to other parts of the world. The campaigns had limited success and were criticized for confusing children into believing that all people they knew were safe.
The earliest citation of the term that I can find in print is from The Austin Daily Herald, February 1963:
The annual policemen's ball, held to raise funds for the Austin Police Benefit Association, will be held Thursday, Feb. 21, at the Terp ballroom. Funds from the ticket sale will be used to help finance association activities including a baseball team... and the Stranger Danger picture (child molestion [sic] warning picture for elementary students).