why does butterworth IIR filter for a square pulse show ripple on edges in time domain but not the same for sine wave
This happens because when lowpass filtering, you remove the high-frequency content that gives the square pulses their sharp edges. Now, if you're not yet versed in Fourier analysis of signals this will be a bit tough, but I'll provide some graphs to show what I mean.
Let's take a simple pulse and a sinusoid like the ones you have. We're going to filter them with a simple 4-th order Butterworth filter. Below are the time-domain and frequency-domain plots of the signals. The spectrum of the filter is also included. The spectrum plots are in decibels (dB).


If you don't know, filtering in the time domain is multiplication in the frequency domain. So you can look at the frequency spectrums and multiply them together, seeing where the attenuation takes place. You can see that the pulse has more significant contributions from high frequencies compared to the sinusoid. So after filtering, the sinusoid will be less distorted than the pulse which is exactly what we see below

We can take this a step further and remove more frequency content by using a tighter filter. Below are the same spectrums with the new filter. You see that the pulse is now even more distorted, while the sinusoid remains relatively unchanged.