A man who murdered a convicted sex offender has been jailed for life and ordered to serve a minimum of 20 years in prison.