Because He was totally God, He was fully capable of taking upon Himself the sin debt and punishment of the whole human race.
Watch the Teaching: Why Did Paul Say the Godhead Dwells in a Body?