There were two main reasons for the fact that the Athenians lost. Both can be called bad luck to some degree.
The first cause of the defeat was a plague. When the war started, the Spartans invaded Athenian territory with their more powerful army. The Athenians withdrew within their walls and relied on their navy. However, the crowding inside the walls caused unsanitary conditions that led to the plague. The plague killed somewhere in the range of 1/3 of all the Athenians, including their leader, Pericles. This reduced the number of men available to fight. It deprived Athens of its greatest leader, and it made Athenians worried that the gods were against them.
Later, Athens suffered from a bad choice of leaders. The Athenians chose Alcibiades, a nephew of Pericles, as their leader. He was reckless and launched an ill-advised invasion of Syracuse. When he lost, he was charged having committed impious acts. When this happened, Alcibiades defected to Sparta. He advised the Spartans on how to defeat the Athenians. This led the Spartans to seek Persian help and to foment rebellion among Athenian territories. This, of course, weakened Athens badly and led to its defeat.
These were the two main factors that caused Athens to lose the war.