Peter"s "why" question to her means virtually the same thing as his "why" question to Ananias ( Acts 5:3). Putting God to the test means seeing how far one can go in disobeying God-in this case lying to Him-before He will judge (cf. Deuteronomy 6:16; Matthew 4:7). This is very risky business. [source][source][source]
Some readers of Acts have criticized Peter for dealing with Sapphira and Ananias so harshly. Nevertheless the text clearly indicates that in these matters Peter was under the Holy Spirit"s control ( Acts 4:31) even as Ananias and Sapphira were under Satan"s control ( Acts 5:3). Peter had been God"s agent of blessing in providing healing to people ( Acts 3:6), but he was also God"s instrument to bring judgment on others, as Jesus Christ had done. [source][source][source]
"Peter was severe, and the fate of the two delinquents shocking, but the strictures of Christ on hypocrisy must be borne in mind (Mt. xxiii).... The old "leaven of the Pharisees" was at work, and for the first time in the community of the saints two persons set out deliberately to deceive their leaders and their friends, to build a reputation for sanctity and sacrifice to which they had no right, and to menace, in so doing, all love, all trust, all sincerity. And not only was the sin against human brotherhood, but against the Spirit of God, so recently and powerfully manifest in the Church." [1][source]