What happened with this LM386 Amplifier Output
The waveform distinctly shows that the LM386 is not an amplifier with the bandwidth or output slew rate capable of amplifying your input waveform that has basically square edges. 

The LM386 is considered to be an audio power amplifier which would mean that it would be typically capable of handling sine wave type audio frequencies from about 100Hz up to about 20kHz in a real application. 

The part is speced to have a bandwidth of typically 300KHz when the gain is at its default level of 20. Of course that is for sine wave signals. At the large wave signal you are feeding you will come no where close to that.