The main function of plasmids is to carry genes that can provide advantages such as antibiotic resistance. They are also used as cloning vectors in genetic engineering.