As far as the theory is concerned, Pagination simply means fetching the data in chunks or "pages" rather than fetching it all at once. The obvious advantages are reduced server/database load since only records that are required to be displayed/processed are retrieved. Pagination becomes a necessity when dealing with user requests/queries which fetch thousands of records due to the unacceptable time delay in fetching the records & displaying/rendering them.
There is also a concept of client side pagination which involves fetching the entire data *but* displaying only a section of that data to the client. The advantages of this approach are purely cosmetic (displaying data to user as and when required) and it still suffers from the performance problems mentioned above.
As far as implementation is concerned, you can refer this article for ideas.