But Socrates was still brought to trial for his supposed atheism. If the whole of Greek society was basically secular in their day to day life, how could such a trial take place?
Easy.
Firstly, he wasn't brought to trial for atheism, but rather for supposedly expounding a different sort of god. This alone was a false accusation, as his defence stated that he did indeed reverence the gods. What he had done was say that he heard voices (yes, he was likely crazy), which he spoke of as ta daimonia, or 'deities'. Now, this was by and large harmless, but his opponents and enemies used this to bring the charge against him that he was corrupting the youth with foreign gods. You see, the Greeks were still strongly religious, it is only that they approached it all ciritically*. Now, none of this explains Socrates' death, because all these accusations were mere excuses (he was also charged on behalf of the playwrites and the magistrates, I beleive.) He had basically made such a nuisance of himself that he was mocked from Aristophanes' comedies onward (and it seems he thought that those plays gave people a negative impression of him, which led to his death.) Furthermore, there is also the idea that he had supported the ten tyrants (or was it twelve? I forget) that Sparta had introduced after victoring in the Peloponnesian war. Socrates' death came right after this situation, and was at the hands of the new Democrats. A bit fishy.
Finally, the true fault for Socrates' death might be Socrates himself. I think Xenophon, a pupil of his (but who didn't see the trial) suggest that he even wanted to die. The man was 60, and after that age he would have had to deal with the rigours of old age. Perhaps he simply didn't want to lose his physical and mental faculties. Also, the vote against Socrates was very, very close. In the tens (the whole voting group was six hundred or so, I think.) They asked him what he thought his punishment should be, I think suggesting a hefty fine, but he said that for all he had done, he should be given free meals for life. He essentially mocked the judge and jury - contempt of court. They voted again, and this time it was very much against him, and he was condemned to death. If he had truly wanted to, he could have avoided it. But he was fearless of it.
The end point is though that neither was Socrates killed for atheism (as he was strongly religious, holding certain things to be 'in the realm of the gods'), nor was the charge against him really on those grounds. It was all a sham trial.
*You see, it is not as we usually consider things today, those who are either hyper religious or atheists. They merely had a distinction between the two. The gods just didn't rule and control everything they did - they didn't live under a theocracy. But that doesn't mean the gods must be removed. It is rather like my brand of Christianity. I believe very strongly in God, yet I seperate the kingdom of the Right and the kingdom of the Left - in the world, there is civil law, morals, duty and responsability that is really seperate from my religion. It's compartamentalising, I suppose. A very different society from that which we see today.