Why Is Zero padding Required for Sobel Edge Eetection?
The Sobel Filter is a $ 3 \times 3 $ matrix (it is separable, but let's ignore that).

The anchor pixel is the middle one hence to evaluate the operator on pixels on the upper row the operator needs data above them.
Same goes for pixels on the last row,  left-most column or  right-most column.

This is usually solved by padding the image (I actually use "Replication" instead of Zero Padding).

Another option is to set the output to be smaller image by not evaluating the extreme rows or columns.