The shapes and patterns you see in Nature can be explained often by the functions that an organism has to perform. These shapes are subject to the laws of physics and the confines of space, but they are also the result of billions of years of evolution. The natural selection associated with this evolution has tended to extinguish forms that were not successful within a dominant environment. What we see around us are the forms that worked.
The DNA structure is a double helix and this shape has certain advantages: its symmetry allows it to be split into two equal parts in order to replicate. The ordering of its nucleotides, where cytosine always pairs with guanine and adenine always pairs with thymine, was an important clue to the discoverers of the DNA structure. This complementary arrangement also guarantees that two new halves of the structure can be joined easily, like pieces in a jigsaw puzzle. Finally the spiral shape encloses the precious information of the nucleotides on the inside within the protective coils of the sugar-phosphate backbone.
Thinking about form and function is a good way to investigate Nature and solve some of its mysteries.