[verb (dictionary form)] + に越したことはない [verb ない-form] + に越したことはない [i-adj] + に越したことはない [na-adj] + に越したことはない [na-adj] + であるに越したことはない [noun] + に越したことはない [noun] + であるに越したことはない
に越したことはない means "nothing beats ~", "it's best if ~": the thing before it is the ideal, though not strictly necessary. It goes after the dictionary form or ない-form of a verb and after an い-adjective. A noun or a な-adjective takes it directly, with no な or だ, or with である in formal writing.
The literal sense is "nothing surpasses ~". It states what is ideal as general common sense, which is why できれば ("if possible") and もちろん ("of course") so often come with it.
The second half of the sentence often turns: X is ideal, but it isn't essential. に越したことはない followed by が or けど sets that up.