The first name Ernest has exactly the same sound as the adjective earnest. The adjective is defined as being serious, sincere and constant in intention or purpose. The way the pun works is through homophony (words that are written differently but sound exactly the same). The words Ernest (noun proper) and earnest (adjective) are not only homophones but heterographs (words that though very similar are spelled differently).
With this context in mind, the pun works in the sense that Cecily is stating that she finds the name Ernest trustworthy because it “inspires confidence” and it does because it is homophonic to the adjective earnest. What she implies is that she is looking for sincere, true, sincere and constant love and that married women (especially in Victorian England) lacked such love in their own marriages.
Wilde’s pay was a sharp and witty criticism of the Victorian mores of his time. There are also homosexual undertones to the play as characterized by the need to play a public persona that allows the real person to live a secret existence more in accordance to his/her own nature and inclinations.