The Israelites sinned greatly by making for themselves a golden calf (after everything the Lord had done for them!). And so to change their hearts, God gave them a multitude of laws. God gave them external actions to change their internal reality. The worship of cows was the "in" thing to do in those days. Egypt and other neighboring nations did that. What God was doing in handing out laws was shifting gears so the people would see it was only God they should worship.
It would seem harsh for us to banish a leper from society but the casting out of lepers is like what the stain of sin does to us. It alienates us from others. It is a disfiguring affliction that gnaws at us until we are broken down, weighed and found wanting.
Without Jesus, sin would just make us unfit for company. We ourselves "hide" away (like Adam and Eve did when they ate the forbidden fruit). Sin eventually rears its ugly head in our lives and it is a "curse" on us, a heavy weight on our hearts. With Jesus we have a way to be cleansed and made whole again. When we seek out Jesus, He won't shrink back from our ugliness but touch us! And we, like the healed leper with skin like