General method of the relativistic Foldy-Wouthuysen transformation and proof of validity of the Foldy-Wouthuysen Hamiltonian