$? is variable in which the exit status of the last command is stored.
0 - Sucessful execution of command
1 - Error
The importance of this variable in shell scripting is that
"In a shell script, the error message is ignored and the script continues to execute. For this reason, it is necessary to check whether a program exited successfully."
Hope this helps.
Amit