To discipline the person not to commit the sin again. To make it more difficult to sin
However not all sins have Kafara. There are some, most notably is the breaking of the fast in Ramadan.
God can forgive the sins however one of the conditions for forgiving is sincerity. A person who is sincere will quickly take care of the kaffara.
The majority of the sins don’t have kafara. A person just does repentance with sincerity and God forgives.