The letters that comprise DNA and RNA are not the only possible nucleobases. Other molecules make the grade in fitting into a double helix.
There is much more to the code than chemical composition. The nucleic acids are but the atomic nuclei of a larger scale system of information storage. Nature cohered to a form from a myriad of considerations, including element availability, spatial arrangement, and energy tradeoffs.