Stephen King, right?
The first 'it' is the effort
The second 'it' is worth
So, 'if it was worth it' means - if the effort of doing something is equal to the worth or benefit that you receive.
Example: I spent 2 hours cleaning my house, but I'm not sure it was worth it, as it still looks untidy!
Hope this helps.