Here's my 5 cents....
Acts 4:32-35 presents an idealized view of the original Christian community, which was along classic Ebionite lines -- followers of Jesus were supposed to live in poverty with no personal property (cf. Luke 12:33, "Sell your possessions and give alms," and Luke 18:18-23 in which the rich aristocrat was told to "sell all that you own and distribute the money to the poor"); thus "all those who owned land or houses would sell them and bring the money from them to present it to the apostles; it was then distributed to any members who might be in need" (Acts 4:34-35). In the story, Ananias and Sapphira try to deceive the apostle Peter by withholding some of the money for themselves by claiming they received less money than they really did. The lie was worse than the fraud itself because they had to lie to Holy Spirit in order to get away with their financial gain. Previously, in Acts 4:8, we read that Peter was "filled with the Holy Spirit" and "spoke by the Holy Spirit" (v. 25), and more importantly the Holy Spirit is presented as personally directing the Christian mission (Acts 13:2, 16:6, 20:23, 28). In this respect, lying to Peter was viewed as the same as lying to the Holy Spirit. The same principle applies in 1 Thessalonians 4:8 which presents the apostle as the representative of God and his Holy Spirit: "He who rejects this instruction does not reject man but God, who gives you his Holy Spirit". Another important parallel with Paul can be found in 1 Corinthians 10:9:
"We are not to put the Lord to the test; some of them [that is, the Israelites in the wilderness] did, and they were killed by snakes" (1 Corinthians 10:9).
Here Paul refers to divine punishment to those in the past who "put the Lord to the test" (the allusion is to Numbers 21:5-6), and Acts 5:9 similarly declares that Ananias and Sapphira "agreed to put the Spirit of the Lord to the test" who then receive death as their punishment. In fact, the phrase of "putting the Lord to the test" is derived from Deuteronomy 6:16 and is also cited in Luke 4:12 as Jesus' response to the Devil's request to throw himself down from the Temple parapet. God may test man but man is forbidden from testing God. Apparently, the author of Acts believed that the act of defrauding the Holy Spirit was tantamount to testing the Spirit. And so, in pure OT fashion, Ananias and Sapphiara are presented as paying with their lives. (Perhaps there is also a connection with Luke 12:10 regarding "blasphemy against the Holy Spirit" which is the unforgiveable sin). It doesn't seem like such a serious crime to us, but apparently the author of Acts and his community took these things very seriously. There may be another parallel in 1 Corinthians 11:28-32 relating to another seemingly inocuous activity, eating of the Lord's Supper, which is treated as a very serious and sacred matter:
"A person who eats and drinks without recognizing the Body is eating and drinking to his own condemnation. In fact, that is why many of you are weak and ill and some of you have died. If only we recollected ourselves, we should not be punished like that. But when the Lord does punish us like that, it is to correct us and stop us from being condemned with the world" (1 Corinthians 11:28-32).
I think this situation is quite similar to that of Ananias and Sapphira in Acts 5, with divine punishment being meted out to those who abuse the sacraments.