echo 'Nothing so needs reforming as other peoples' habits.'
echo 'Nothing so needs reforming as other peoples'\'' habits.'
or
echo "Nothing so needs reforming as other peoples' habits."
When writing a string in single-quotes, you have to make sure that any apostrophes in the text don't accidentally terminate the single-quoted string prematurely.
Escape them properly (see the correct code) or switch quotes to avoid the problem.
echo '...peoples\ habits.'
...peoples\ habits.
$ echo $'...peoples\x27 habits.'
...peoples' habits.
None.
https://www.gnu.org/software/bash/manual/html_node/Quoting.html
ShellCheck is a static analysis tool for shell scripts. This page is part of its documentation.