Spanish law does not say anything about this, so the principle of party autonomy applies. This means that a person can refuse to undergo the medical check-up but, in that case, it is very possible that the insurer will refuse to issue the insurance policy.
For certain types of life insurance policies, insurance companies need to know the state of health of their policyholders, as well as other issues, in order to assess the risk faced and, consequently, adjust the premium accordingly.