The main function of a computer is to process and store data, perform calculations, and execute tasks based on instructions provided by the user or software programs. It can also communicate with other devices and access the internet to retrieve information. Essentially, a computer is a versatile tool that can be used for a wide range of purposes, including word processing, multimedia editing, gaming, and more.