I need to be honest the beginning of Acts 5 confuses me. The church has been growing super fast, people were being healed, the gospel was spreading. Then God decides to freak everyone out by killing someone who gave money to the church.
I should be clear here, Ananias and Sapphira conspired together to gain favor in the fledgling church by appearing spiritual in an act of giving. They decided together to sell some land and give part of the money to the apostles and make seem as though they had given all the money they received. Peter being full of the Spirit knew they were attempting to deceive the body of believers and, more importantly, God himself. Peter called them out and both were struck dead.
This strikes fear in my own life because I feel I've committed equally, if not worse, sins against God my savior. God clearly is the author of life and is sovereign over all, so he can at any point exact his wrath or demonstrate his mercy. That said, I believe God used this event as an example rather than a norm to establish and centralize the leadership of the early church and further build the church's foundation. Jesus says to Peter and the rest of the twelve that on them he'll build his church. If Ananias and Sapphira were able to get away with this, you'd have seen enemies of the church weasel their way into leadership and disintegrate its foundation and credibility.
What God did worked. People were hesitant to join the believers out of fear, but still received the gospel in droves. The Sanhedrin, naturally, became jealous and sought to prevent the apostles from preaching more. A respected leader wisely prevented them from carrying out any capital punishment on the apostles by arguing that if these men were not aided by God himself their movement would die. God in his wisdom used the deaths of Ananias and Sapphira to ensure that the movement would in fact be completely led by his Spirit.
As we'll see later on in Acts, this is one of many events that God used to ensure the fidelity of this new movement.