General contact mechanics theory for randomly rough surfaces with application to rubber friction